﻿#include "derivedata.h"
#include "ui_derivedata.h"
extern QString filep;
extern QString isc;
extern QString outpath;
extern int doutfl;
derivedata::derivedata(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::derivedata)
{
    ui->setupUi(this);
    ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    ui->tableWidget->verticalHeader()->setDefaultSectionSize(30);
    ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    ui->tableWidget->horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);

    QString sql="Select CycleNum From AmplStep where ProgramId=(Select AmplGuid from ExperimentInfo) and IsCollect='是'";
    query.exec(sql);
    while (query.next()) {
        xhval=query.value("CycleNum").toInt();
    }
}

derivedata::~derivedata()
{
    delete ui;
}
QString derivedata::GetChartQueryPosition(){
    QString queryRuleString;
    QString sql=QString("SELECT distinct PositionNumber FROM SampleInfo s "
                        "join FluorescenceData f on s.id=f.sampleid "
                        "where 1=1 %1  "
                        "order by f.PositionNumber").arg(queryRuleString);
    return  sql;

}
//刷新原始曲线
void derivedata::refOriginalCurveChart(){
    myChart = new QChart();
    allOrigLines.clear();

    QStringList accessList;
    QString queryString;
    accessList<<"FAM";
    queryString+="FAM,";
    accessList<<"ROX";
    queryString+="ROX,";
    accessList<<"VIC";
    queryString+="VIC,";
    accessList<<"CY5";
    queryString+="CY5,";
    queryString = queryString.left(queryString.length()-1);

    QValueAxis * axisY = new QValueAxis(myChart);//Y轴
    QValueAxis * axisX = new QValueAxis(myChart);//X轴为时间轴

    myChart->addAxis(axisY,Qt::AlignmentFlag::AlignLeft);//绑定Y轴到图表左侧
    myChart->addAxis(axisX,Qt::AlignmentFlag::AlignBottom);//绑定X轴到图表底部

    QString sql= GetChartQueryPosition();

    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);
    query.exec(sql);
    QList<QVariantMap> positionList;
    int maxY=0;

    while(query.next()){
        QVariantMap map;
        for (int i = 0; i < query.record().count(); ++i) {
            map[query.record().fieldName(i)] = query.value(i);
        }
        positionList.append(map);
    }
    for(int i=1;i<=positionList.length();i++){
        sql=getChartQuerySql(queryString,"FluorescenceData",positionList[i].value("PositionNumber").toString());
        query.exec(sql);

        QList<QVariantMap> resultList;

        while (query.next()) {
            QVariantMap map;
            for (int i = 0; i < query.record().count(); ++i) {
                map[query.record().fieldName(i)] = query.value(i);
            }
            resultList.append(map);
        }

        for(int m=0;m<accessList.count();m++){
            QSplineSeries* line = new QSplineSeries();//光滑曲线;
            allOrigLines.append(line);
            myChart->addSeries(line);//添加曲线
            for (int n=0;n<resultList.length();n++) {
                line->append(QPointF(resultList[n].value("CyclesNumber").toInt(),resultList[n].value(accessList[m]).toReal()));
                if(resultList[n].value(accessList[m]).toReal()>maxY){
                    maxY=(qFloor(resultList[n].value(accessList[m]).toReal()/4000)+1)*4000;
                }
            }

            if(accessList[m]=="FAM"){
                line->setPen(QPen(QColor(66,46,205)));
            }else if(accessList[m]=="ROX"){
                line->setPen(QPen(QColor(255,135,62)));
            }else if (accessList[m]=="CY5") {
                line->setPen(QPen(QColor(255,43,55)));
            }else if(accessList[m]=="VIC"){
                line->setPen(QPen(QColor(0,196,115)));
            }

            line->attachAxis(axisX);//曲线绑定到X轴，必须在坐标轴绑定刻度之后，否则图像不准
            line->attachAxis(axisY);//曲线绑定到Y轴，必须在坐标轴绑定刻度之后，否则图像不准
        }
    }

    axisY->setTitleText("荧光强度(Rn)");
    axisY->setRange(0,maxY);
    axisY->setLabelFormat("%.0f");
    if(maxY>20000){
        axisY->setTickCount(maxY/4000+1);
    }else{
        axisY->setTickCount(maxY/2000+1);
    }

    axisX->setTitleText("循环数(Cycles)");
    axisX->setLabelFormat("%.0f");
    axisX->setRange(1,analyseClient->leh);
    axisX->setTickCount(analyseClient->leh);

    // 主网格线
    axisX->setGridLineVisible(true);
    axisX->setGridLineColor(Qt::darkGray);
    axisY->setGridLineVisible(true);
    axisY->setGridLineColor(Qt::darkGray);

    QLegend *legend=myChart->legend();
    legend->setVisible(false);//隐藏图例
    ui->graphicsView->setRenderHint(QPainter::RenderHint::Antialiasing);//开启抗锯齿，否则曲线会有毛刺
    ui->graphicsView->setChart(myChart);//将图表放到画布上
}

//刷新原始曲线数据表
void derivedata::refOriginalCurveTable(){
    ui->tableWidget->blockSignals(true);

    ui->tableWidget->setRowCount(0);
    QList<QString> rowInfoList;
    rowInfoList<<""<<"孔位"<<"样本名"<<"检测类型"<<"荧光染料";

    ui->tableWidget->setColumnCount(rowInfoList.length());
    ui->tableWidget->setHorizontalHeaderLabels(rowInfoList);
    ui->tableWidget->setColumnHidden(0, true); // 隐藏第1列
    QString queryString;
    queryString+="'FAM',";
    queryString+="'VIC',";
    queryString+="'ROX',";
    queryString+="'CY5',";
    queryString = queryString.left(queryString.length()-1);

    QString queryRuleString;


    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);

    QList<QString> label;
    label<<""<<"RealPos"<<"SampleName"<<"SampleType"<<"AccessName";
    int rowNum=0;

    QString  sql=QString( "select distinct  "
                          "(select Name from ItemCode where dicCode=3 and Code=PositionNumber) as RealPos,"
                          "SampleName,SampleType,"
                          "sa.AccessName "
                          "from sampleInfo s "
                          "join SampleAccessInfo sa on s.ID = sa.SampleGuid "
                          "join FluorescenceData f on s.ID = f.SampleId "
                          "where sa.AccessName in (%1) %2 "
                          "order by PositionNumber,CyclesNumber;").arg(queryString,queryRuleString);

    query.exec(sql);
    while (query.next()) {
        ui->tableWidget->insertRow(rowNum);
        QTableWidgetItem *item = new QTableWidgetItem(QString::number(rowNum));
        ui->tableWidget->setItem(rowNum, 0, item);
        for(int m=1;m<label.length();m++){
            QTableWidgetItem *item = new QTableWidgetItem(query.value(label[m]).toString());
            ui->tableWidget->setItem(rowNum, m, item);
        }
        rowNum++;
    }
    ui->tableWidget->blockSignals(false);
}
QString derivedata::getChartQuerySql(QString queryCol,QString queryTable,QString PositionNumber){
    QString  sql=QString("select CyclesNumber,%1 "
                         "from  %2 f "
                         "where PositionNumber='%3' "
                         "order by PositionNumber,CyclesNumber;").arg(queryCol,queryTable,PositionNumber);
    return  sql;
}
//刷新扩增曲线
void derivedata::refAmplificationCurveChart(){
    myChart = new QChart();
    allAmplLines.clear();

    QStringList accessList;
    QString queryString;
    accessList<<"FAM";
    queryString+="FAM,";
    accessList<<"ROX";
    queryString+="ROX,";
    accessList<<"VIC";
    queryString+="VIC,";
    accessList<<"CY5";
    queryString+="CY5,";

    queryString = queryString.left(queryString.length()-1);
    axisY = new QValueAxis(myChart);
    axisX = new QValueAxis(myChart);

    myChart->addAxis(axisY,Qt::AlignmentFlag::AlignLeft);//绑定Y轴到图表左侧
    myChart->addAxis(axisX,Qt::AlignmentFlag::AlignBottom);//绑定X轴到图表底部


    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);
    QString sql= GetChartQueryPosition();
    query.exec(sql);
    QList<QVariantMap> positionList;
    int maxY=0;

    while(query.next()){
        QVariantMap map;
        for (int i = 0; i < query.record().count(); ++i) {
            map[query.record().fieldName(i)] = query.value(i);
        }
        positionList.append(map);
    }

    for(int i=1;i<=positionList.length();i++){

        QString sql=getChartQuerySql(queryString,"FluorescenceLvData",positionList[i].value("PositionNumber").toString());
        query.exec(sql);

        QList<QVariantMap> resultList;

        while (query.next()) {
            QVariantMap map;
            for (int i = 0; i < query.record().count(); ++i) {
                map[query.record().fieldName(i)] = query.value(i);
            }
            resultList.append(map);
        }

        for(int m=0;m<accessList.count();m++){
            QSplineSeries* line = new QSplineSeries();//光滑曲线
            allAmplLines.append(line);
            myChart->addSeries(line);//添加曲线
            for(int n=0;n<resultList.length();n++)
            {
                line->append(QPointF(resultList[n].value("CyclesNumber").toInt(),resultList[n].value(accessList[m]).toReal()));
                line->setName(QString::number(i)+"."+accessList[m]);
                if(resultList[n].value(accessList[m]).toReal()>maxY){
                    maxY=(qFloor(resultList[n].value(accessList[m]).toReal()/4000)+1)*4000;
                }
            }

            if(accessList[m]=="FAM"){
                line->setPen(QPen(QColor(66,46,205)));
            }else if(accessList[m]=="ROX"){
                line->setPen(QPen(QColor(255,135,62)));
            }else if (accessList[m]=="CY5") {
                line->setPen(QPen(QColor(255,43,55)));
            }else if(accessList[m]=="VIC"){
                line->setPen(QPen(QColor(0,196,115)));
            }

            line->attachAxis(axisX);//曲线绑定到X轴，必须在坐标轴绑定刻度之后，否则图像不准
            line->attachAxis(axisY);//曲线绑定到Y轴，必须在坐标轴绑定刻度之后，否则图像不准
        }
    }

    axisX->setLabelFormat("%.0f");
    axisX->setRange(1,analyseClient->leh);
    axisX->setTitleText("循环数(Cycles)");
    axisX->setTickCount(analyseClient->leh);

    axisY->setTitleText("荧光强度(△Rn)");
    axisY->setRange(0,maxY);
    axisY->setLabelFormat("%.0f");
    if(maxY>20000){
        axisY->setTickCount(maxY/4000+1);
    }else{
        axisY->setTickCount(maxY/2000+1);
    }

    // 主网格线
    axisX->setGridLineVisible(true);
    axisX->setGridLineColor(Qt::darkGray);
    axisY->setGridLineVisible(true);
    axisY->setGridLineColor(Qt::darkGray);

    QLegend *legend=myChart->legend();
    legend->setVisible(false);//隐藏图例
    ui->graphicsView->setRenderHint(QPainter::RenderHint::Antialiasing);//开启抗锯齿，否则曲线会有毛刺
    ui->graphicsView->setChart(myChart);//将图表放到画布上
}

//刷新扩增曲线数据表
void derivedata::refAmplificationCurveTable(){
    ui->tableWidget->blockSignals(true);

    ui->tableWidget->setRowCount(0);
    QList<QString> rowInfoList;
    rowInfoList<<""<<"孔位"<<"样本名"<<"检测类型"<<"荧光染料"<<"CT值"<<"浓度值";

    ui->tableWidget->setColumnCount(rowInfoList.length());
    ui->tableWidget->setHorizontalHeaderLabels(rowInfoList);
    ui->tableWidget->setColumnHidden(6, true); // 隐藏第7列

    QString queryString;
    queryString+="'FAM',";
    queryString+="'VIC',";
    queryString+="'ROX',";
    queryString+="'CY5',";
    queryString = queryString.left(queryString.length()-1);

    QString queryRuleString;

    QString  sql=QString("select distinct "
                         "(select Name from ItemCode where dicCode=3 and Code=PositionNumber) as RealPos,"
                         "SampleName,"
                         "SampleType,"
                         "sa.AccessName,sa.CtValue,"
                         "CASE WHEN "
                         "S.SampleType='标准品' then SampleConc "
                         "else '' end as SampleConc "
                         "from sampleInfo s "
                         "join SampleAccessInfo sa on s.ID=sa.SampleGuid "
                         "join FluorescenceData f on s.ID=f.SampleId "
                         "where sa.AccessName in (%1) %2 "
                         "order by SampleType,PositionNumber,CyclesNumber;").arg(queryString,queryRuleString);
    QList<QString> label;
    label<<""<<"RealPos"<<"SampleName"<<"SampleType"<<"AccessName"<<"CtValue"<<"SampleConc";

    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);
    query.exec(sql);
    int rowNum=0;
    while (query.next()) {
        ui->tableWidget->insertRow(rowNum);
        QTableWidgetItem *item = new QTableWidgetItem(QString::number(rowNum));
        ui->tableWidget->setItem(rowNum, 0, item);
        for (int m=1;m<label.length();m++) {
            QTableWidgetItem *item = new QTableWidgetItem(query.value(label[m]).toString());
            ui->tableWidget->setItem(rowNum, m, item);
        }
        rowNum++;
    }
    ui->tableWidget->blockSignals(false);
}

// 标准曲线初始化
void derivedata::standardCurveChart()
{
    bzsum=0;
    for(int i=0;i<ui->tableWidget->rowCount();i++){
        if(ui->tableWidget->item(i,3)->text()=="标准品"){
            bzsum+=1;
        }
    }
    if(true){
        myChart = new QChart();

        bzROX = new QLineSeries();
        bzVIC = new QLineSeries();
        bzFAM = new QLineSeries();
        bzCY5 = new QLineSeries();
        bzsdROX = new QScatterSeries();
        bzsdVIC = new QScatterSeries();
        bzsdFAM = new QScatterSeries();
        bzsdCY5 = new QScatterSeries();
        fbzROX = new QScatterSeries();
        fbzVIC = new QScatterSeries();
        fbzFAM = new QScatterSeries();
        fbzCY5 = new QScatterSeries();
        QValueAxis *m_axisX = new QValueAxis();
        QValueAxis *m_axisY = new QValueAxis();
        m_axisX->setTickCount(5);
        m_axisY->setTickCount(8);
        m_axisX->setMin(-4.0);
        m_axisY->setMin(10);
        m_axisX->setMax(1);
        m_axisY->setMax(45);
        myChart->addAxis(m_axisX, Qt::AlignBottom);                      // 将X轴添加到图表上
        myChart->addAxis(m_axisY, Qt::AlignLeft);                    // 将Y轴添加到图表上
        myChart->axisX()->setTitleText("浓度");
        myChart->axisY()->setTitleText("CT值");
        QVector<double> xrox,yrox,yvic,yfam,ycy5;
        for(int i=0;i<ui->tableWidget->rowCount();i+=4){
            if(ui->tableWidget->item(i,3)->text()=="标准品"){
                xrox.append(ui->tableWidget->item(i+1,6)->text().toDouble());
                yrox.append(ui->tableWidget->item(i+1,5)->text().toDouble());
                yvic.append(ui->tableWidget->item(i+2,5)->text().toDouble());
                yfam.append(ui->tableWidget->item(i,5)->text().toDouble());
                ycy5.append(ui->tableWidget->item(i+3,5)->text().toDouble());
            }
        }
        QVector<double> logxrox=logvalue(xrox);
        // 线性回归计算

        calculateLinearRegression(xrox, yrox, krox, brox, r2rox, curox);
        calculateLinearRegression(xrox, yvic, kvic, bvic, r2vic, cuvic);
        calculateLinearRegression(xrox, yfam, kfam, bfam, r2fam, cufam);
        calculateLinearRegression(xrox, ycy5, kcy5, bcy5, r2cy5, cucy5);

        QPen pen;
        pen.setColor(QColor(255,165,0));
        pen.setWidth(2);
        bzROX->setPen(pen);
        bzsdROX->setPen(pen);
        fbzROX->setPen(pen);
        QBrush brush; // 设置填充颜色
        brush.setColor(QColor(255,165,0));
        bzsdROX->setBrush(brush);
        fbzROX->setBrush(brush);

        pen.setColor(QColor(Qt::green));
        pen.setWidth(2);
        bzVIC->setPen(pen);
        bzsdVIC->setPen(pen);
        fbzVIC->setPen(pen);
        brush.setColor(QColor(Qt::green));
        bzsdVIC->setBrush(brush);
        fbzVIC->setBrush(brush);

        pen.setColor(QColor(Qt::blue));
        pen.setWidth(2);
        bzFAM->setPen(pen);
        bzsdFAM->setPen(pen);
        fbzFAM->setPen(pen);
        brush.setColor(QColor(Qt::blue));
        bzsdFAM->setBrush(brush);
        fbzFAM->setBrush(brush);

        pen.setColor(QColor(Qt::red));
        pen.setWidth(2);
        bzCY5->setPen(pen);
        bzsdCY5->setPen(pen);
        fbzCY5->setPen(pen);
        brush.setColor(QColor(Qt::red));
        bzsdCY5->setBrush(brush);
        fbzCY5->setBrush(brush);

        bzsdROX->setMarkerShape(QScatterSeries::MarkerShape::MarkerShapeCircle);
        bzsdROX->setMarkerSize(15);
        bzsdVIC->setMarkerShape(QScatterSeries::MarkerShape::MarkerShapeCircle);
        bzsdVIC->setMarkerSize(15);
        bzsdFAM->setMarkerShape(QScatterSeries::MarkerShape::MarkerShapeCircle);
        bzsdFAM->setMarkerSize(15);
        bzsdCY5->setMarkerShape(QScatterSeries::MarkerShape::MarkerShapeCircle);
        bzsdCY5->setMarkerSize(15);
        fbzROX->setMarkerShape(QScatterSeries::MarkerShape::MarkerShapeRectangle);
        fbzROX->setMarkerSize(15);
        fbzVIC->setMarkerShape(QScatterSeries::MarkerShape::MarkerShapeRectangle);
        fbzVIC->setMarkerSize(15);
        fbzFAM->setMarkerShape(QScatterSeries::MarkerShape::MarkerShapeRectangle);
        fbzFAM->setMarkerSize(15);
        fbzCY5->setMarkerShape(QScatterSeries::MarkerShape::MarkerShapeRectangle);
        fbzCY5->setMarkerSize(15);

        myChart->addSeries(bzROX);
        myChart->addSeries(bzVIC);
        myChart->addSeries(bzFAM);
        myChart->addSeries(bzCY5);
        myChart->addSeries(bzsdROX);
        myChart->addSeries(bzsdVIC);
        myChart->addSeries(bzsdFAM);
        myChart->addSeries(bzsdCY5);
        myChart->addSeries(fbzROX);
        myChart->addSeries(fbzVIC);
        myChart->addSeries(fbzFAM);
        myChart->addSeries(fbzCY5);

        bzROX->attachAxis(m_axisX);
        bzROX->attachAxis(m_axisY);
        bzVIC->attachAxis(m_axisX);
        bzVIC->attachAxis(m_axisY);
        bzFAM->attachAxis(m_axisX);
        bzFAM->attachAxis(m_axisY);
        bzCY5->attachAxis(m_axisX);
        bzCY5->attachAxis(m_axisY);
        bzsdROX->attachAxis(m_axisX);
        bzsdROX->attachAxis(m_axisY);
        bzsdVIC->attachAxis(m_axisX);
        bzsdVIC->attachAxis(m_axisY);
        bzsdFAM->attachAxis(m_axisX);
        bzsdFAM->attachAxis(m_axisY);
        bzsdCY5->attachAxis(m_axisX);
        bzsdCY5->attachAxis(m_axisY);
        fbzROX->attachAxis(m_axisX);
        fbzROX->attachAxis(m_axisY);
        fbzVIC->attachAxis(m_axisX);
        fbzVIC->attachAxis(m_axisY);
        fbzFAM->attachAxis(m_axisX);
        fbzFAM->attachAxis(m_axisY);
        fbzCY5->attachAxis(m_axisX);
        fbzCY5->attachAxis(m_axisY);

        QLegend *legend = myChart->legend();
        if (legend) {
            // 获取图例标记数组
            QList<QLegendMarker*> markers = legend->markers();
            if (!markers.isEmpty()) {
                // 隐藏第一个系列的图例项
                for(int i=4;i<12;i++){
                    markers[i]->setVisible(false);
                }
            }
        }
        legend->detachFromChart();

        myChart->setMargins(QMargins(0, 0, 0, 160));

        myChart->legend()->setGeometry(QRectF(50,ui->graphicsView->height()-160,500,160));

        myChart->setAnimationOptions(QChart::SeriesAnimations);        // 动画：能使曲线绘制显示的更平滑，过渡效果更好看
        ui->graphicsView->setChart(myChart);                           // 将图表对象设置到graphicsView上进行显示
        ui->graphicsView->setRenderHint(QPainter::Antialiasing);       // 设置渲染：抗锯齿，如果不设置那么曲线就显得不平滑
        bzFAM->append(QPointF(-4,kfam*(-4)+bfam));
        bzFAM->append(QPointF(1,kfam+bfam));
        bzVIC->append(QPointF(-4,kvic*(-4)+bvic));
        bzVIC->append(QPointF(1,kvic+bvic));
        bzROX->append(QPointF(-4,krox*(-4)+brox));
        bzROX->append(QPointF(1,krox+brox));
        bzCY5->append(QPointF(-4,kcy5*(-4)+bcy5));
        bzCY5->append(QPointF(1,kcy5+bcy5));
        for(int i =0;i<xrox.length();i++){
            bzsdROX->append(logxrox[i],yrox[i]);
            bzsdVIC->append(logxrox[i],yvic[i]);
            bzsdFAM->append(logxrox[i],yfam[i]);
            bzsdCY5->append(logxrox[i],ycy5[i]);
        }
        QVector<double> fbzfdata1,fbzvdata1,fbzrdata1,fbzcdata1;
        for(int i=0;i<ui->tableWidget->rowCount();i+=4){
            if(ui->tableWidget->item(i,3)->text()!="标准品"){
                fbzfdata1.append(ui->tableWidget->item(i,5)->text().toDouble());
                fbzvdata1.append(ui->tableWidget->item(i+2,5)->text().toDouble());
                fbzrdata1.append(ui->tableWidget->item(i+1,5)->text().toDouble());
                fbzcdata1.append(ui->tableWidget->item(i+3,5)->text().toDouble());
            }
        }
        double fbzfdata[fbzfdata1.length()],fbzvdata[fbzfdata1.length()],fbzrdata[fbzfdata1.length()],fbzcdata[fbzfdata1.length()];
        for (int i = 0; i < fbzfdata1.length(); ++i) {
            fbzfdata[i] = fbzfdata1[i];
            fbzvdata[i] = fbzvdata1[i];
            fbzrdata[i] = fbzrdata1[i];
            fbzcdata[i] = fbzcdata1[i];
        }

        Analyse analyse;
        analyse.standardK=kfam;
        analyse.standardYInt=bfam;
        std::vector<double> fbzfn10=analyse.Concentration(fbzfdata,ui->tableWidget->rowCount()/4-bzsum/4);
        analyse.standardK=kvic;
        analyse.standardYInt=bvic;
        std::vector<double> fbzvn10=analyse.Concentration(fbzvdata,ui->tableWidget->rowCount()/4-bzsum/4);
        analyse.standardK=krox;
        analyse.standardYInt=brox;
        std::vector<double> fbzrn10=analyse.Concentration(fbzrdata,ui->tableWidget->rowCount()/4-bzsum/4);
        analyse.standardK=kcy5;
        analyse.standardYInt=bcy5;
        std::vector<double> fbzcn10=analyse.Concentration(fbzcdata,ui->tableWidget->rowCount()/4-bzsum/4);
        // 非标准品浓度10计算
        QVector<double> fbzfn,fbzvn,fbzrn,fbzcn;
        for(int i=0;i<fbzfn10.size();i++){
            fbzfn.append(pow(10,fbzfn10[i]));
            fbzvn.append(pow(10,fbzvn10[i]));
            fbzrn.append(pow(10,fbzrn10[i]));
            fbzcn.append(pow(10,fbzcn10[i]));
        }
        // 非标准品散点展示
        for(int i =0;i<fbzfn10.size();i++){
            fbzROX->append(fbzrn10[i],fbzrdata[i]);
            fbzVIC->append(fbzvn10[i],fbzvdata[i]);
            fbzFAM->append(fbzfn10[i],fbzfdata[i]);
            fbzCY5->append(fbzcn10[i],fbzcdata[i]);
        }
        QVector<double> fbznj;
        // 非标准品浓度平均值计算
        for(int i =0;i<fbzfn10.size();i++){
            fbznj.append((fbzfn[i]+fbzvn[i]+fbzrn[i])/3);
        }

        QStringList rowInfoList;
        rowInfoList<<""<<"孔位"<<"样本名"<<"检测类型"<<"荧光染料"<<"Cq值"<<"样本浓度"<<"样本浓度均值";
        ui->tableWidget->setColumnCount(rowInfoList.length());
        ui->tableWidget->setHorizontalHeaderLabels(rowInfoList);
        ui->tableWidget->resizeColumnsToContents(); //根据内容调整列宽
        ui->tableWidget->setColumnHidden(0, true);


        int fbznum=0;
        for(int i=0;i<ui->tableWidget->rowCount();i+=4){
            if(ui->tableWidget->item(i,3)->text()!="标准品"){
                QString stcn= QString::number(fbzcn[fbznum],'f',4);
                QString stfn= QString::number(fbzfn[fbznum],'f',4);
                QString strn= QString::number(fbzrn[fbznum],'f',4);
                QString stvn= QString::number(fbzvn[fbznum],'f',4);
                //
                QString stctcn= QString::number(fbzcdata1[fbznum],'f',4);
                QString stctfn= QString::number(fbzfdata1[fbznum],'f',4);
                QString stctrn= QString::number(fbzrdata1[fbznum],'f',4);
                QString stctvn= QString::number(fbzvdata1[fbznum],'f',4);
                // 表格浓度
                if(stfn=="inf"){
                    ui->tableWidget->setItem(i,6,new QTableWidgetItem("nan"));
                }else{
                    ui->tableWidget->setItem(i,6,new QTableWidgetItem(stfn));
                }
                if(strn=="inf"){
                    ui->tableWidget->setItem(i+1,6,new QTableWidgetItem("nan"));
                }else{
                    ui->tableWidget->setItem(i+1,6,new QTableWidgetItem(strn));
                }
                if(stvn=="inf"){
                    ui->tableWidget->setItem(i+2,6,new QTableWidgetItem("nan"));
                }else{
                    ui->tableWidget->setItem(i+2,6,new QTableWidgetItem(stvn));
                }
                if(stcn=="inf"){
                    ui->tableWidget->setItem(i+3,6,new QTableWidgetItem("nan"));
                }else{
                    ui->tableWidget->setItem(i+4,6,new QTableWidgetItem(stcn));
                }
                // 表格ct
                ui->tableWidget->setItem(i,5,new QTableWidgetItem(stctfn));
                ui->tableWidget->setItem(i+1,5,new QTableWidgetItem(stctrn));
                ui->tableWidget->setItem(i+2,5,new QTableWidgetItem(stctvn));
                ui->tableWidget->setItem(i+3,5,new QTableWidgetItem(stctcn));
                // 平均浓度
                for(int k=0;k<4;k++){
                    QString stjn= QString::number(fbznj[fbznum],'f',4);
                    if(stjn=="inf"){
                        ui->tableWidget->setItem(i+k,7,new QTableWidgetItem("nan"));
                    }else{
                        ui->tableWidget->setItem(i+k,7,new QTableWidgetItem(stjn));
                    }
                    ui->tableWidget->setItem(i+k,7,new QTableWidgetItem(stjn));
                }
                fbznum++;
            }else{
                for(int k=0;k<4;k++){
                    ui->tableWidget->setItem(i+k,7,new QTableWidgetItem(ui->tableWidget->item(i,6)->text()));
                }
            }

        }
        bzFAM->setName("FAM E="+QString::number(cufam)+" R^2="+QString::number(r2fam)+" Slope="+QString::number(kfam)+" y-int="+QString::number(bfam));
        bzVIC->setName("VIC E="+QString::number(cuvic)+" R^2="+QString::number(r2vic)+" Slope="+QString::number(kvic)+" y-int="+QString::number(bvic));
        bzROX->setName("ROX E="+QString::number(curox)+" R^2="+QString::number(r2rox)+" Slope="+QString::number(krox)+" y-int="+QString::number(brox));
        bzCY5->setName("CY5 E="+QString::number(cucy5)+" R^2="+QString::number(r2cy5)+" Slope="+QString::number(kcy5)+" y-int="+QString::number(bcy5));
        if(ui->tableWidget->rowCount()>0){
            qut.clear();
        }
        for(int i=0;i<ui->tableWidget->rowCount();i++){
            qut.append(ui->tableWidget->item(i,7)->text());
        }
        qDebug()<<qut;
    }
}

// 标准曲线值计算
void derivedata::calculateLinearRegression(const QVector<double> &x, const QVector<double> &y, double &k, double &b, double &rSquared,double &cubeRoot)
{
    // 对x值取对数
    QVector<double> logx;
    for (double value : x) {
        if (value > 0) { // 确保不会对0或负数取对数
            logx.push_back(std::log10(value)); // 使用以10为底的对数
        } else {
            // 处理0或负数的情况，例如跳过或设置一个默认值
        }
    }
    int n = logx.size();
    if (n != y.size()) {
        qWarning("X and Y data sizes do not match!");
        return;
    }

    double sumX = 0.0, sumY = 0.0, sumXY = 0.0, sumX2 = 0.0;
    for (int i = 0; i < n; ++i){
        sumX += logx[i];
        sumY += y[i];
        sumXY += logx[i] * y[i];
        sumX2 += logx[i] * logx[i];
    }

    double meanX = sumX / n;
    double meanY = sumY / n;
    k = (n * sumXY - sumX * sumY)/(n * sumX2 - sumX * sumX);
    b = meanY - k * meanX;
    double sumResidualsSquared = 0.0;
    double sumYSquared = 0.0;
    for (int i = 0; i < n; ++i) {
        double residual = y[i] - (k * logx[i] + b);
        sumResidualsSquared += residual * residual;
        sumYSquared += y[i] * y[i];
    }
    double totalVariance = sumYSquared / n - (meanY * meanY);
    if (totalVariance <= 0) {
        rSquared = 0; // 避免除以零
    } else {
        rSquared = 1 - (sumResidualsSquared / totalVariance);
    }
    cubeRoot = std::pow(10, -1.0 / k);
    cubeRoot = (cubeRoot-1)*100;
}

// log取值
QVector<double> derivedata::logvalue(QVector<double> valuelog)
{
    QVector<double> logv;
    for (double value : valuelog) {
        if (value > 0) { // 确保不会对0或负数取对数
            logv.push_back(std::log10(value)); // 使用以10为底的对数
        } else {
            // 处理0或负数的情况，例如跳过或设置一个默认值
        }
    }
    return logv;
}

// 指导建议表格
void derivedata::guide()
{
    QStringList rowInfoList;
    rowInfoList<<" "<<"孔位"<<"样本名"<<"检测类型"<<"荧光染料"<<"Cq值"<<"样本浓度\nng/ul"<<"总浓度\nng/ul"<<"男性浓度\nng/ul"<<"女性浓度\nng/ul"
              <<"男女浓度比例"<<"降解指数DI"<<"抑制指数ICS"<<"检测方案"<<"稀释方案\n样本体积\nul"<<"稀释方案\n稀释液体积\nul"<<"扩增上样体积\nul"<<"备注";
    ui->tableWidget->setColumnCount(rowInfoList.length());
    ui->tableWidget->setHorizontalHeaderLabels(rowInfoList);
    ui->tableWidget->resizeColumnsToContents(); // 根据内容调整列宽
    ui->tableWidget->setColumnHidden(0, true);
    //总浓度值
    for(int i=0;i<ui->tableWidget->rowCount();i++){
        if(i%4==0){
            ui->tableWidget->setItem(i,7, new QTableWidgetItem(ui->tableWidget->item(i+2,6)->text()));
        }else if(i%4==1){
            ui->tableWidget->setItem(i,7,new QTableWidgetItem(ui->tableWidget->item(i+1,6)->text()));
        }else if(i%4==2){
            ui->tableWidget->setItem(i,7,new QTableWidgetItem(ui->tableWidget->item(i,6)->text()));
        }else if(i%4==3){
            ui->tableWidget->setItem(i,7,new QTableWidgetItem(ui->tableWidget->item(i-1,6)->text()));
        }
    }
    //标准品CQ浓度平均值
    double valCJ=0;
    int ctNum=0;
    for(int i=0;i<ui->tableWidget->rowCount();i+=4){
        if(ui->tableWidget->item(i+1,3)->text()=="标准品"){
            valCJ+=ui->tableWidget->item(i+3,5)->text().toDouble();
            ctNum++;
        }
    }
    valCJ=valCJ/ctNum;
    //样本名相同处理
    QStringList ybmsame;
    for(int i=0;i<ui->tableWidget->rowCount();i+=4){
        if(!ybmsame.contains(ui->tableWidget->item(i,2)->text())){
            ybmsame.append(ui->tableWidget->item(i,2)->text());
        }
    }
    QList<int> ybmnum;
    QList<double> AL,AS,Y,CQ;
    for(int i=0;i<ybmsame.length();i++){
        ybmnum.append(0);
        AL.append(0);
        AS.append(0);
        Y.append(0);
        CQ.append(0);
    }
    for (int i=0;i<ui->tableWidget->rowCount();i+=4) {
        QString cell_value = ui->tableWidget->item(i+1,2)->text();
        for(int j = 0;j<ybmsame.length();j++){
            if(cell_value==ybmsame[j]){
                double cell_valueAL = QString::number(ui->tableWidget->item(i+1,6)->text().toDouble(),'f',4).toDouble();
                double cell_valueAS = QString::number(ui->tableWidget->item(i+2,6)->text().toDouble(),'f',4).toDouble();
                double cell_valueY = QString::number(ui->tableWidget->item(i,6)->text().toDouble(),'f',4).toDouble();
                double cell_valueCQ = QString::number(ui->tableWidget->item(i+3,5)->text().toDouble(),'f',4).toDouble();
                AL[j]+=cell_valueAL;
                AS[j]+=cell_valueAS;
                Y[j]+=cell_valueY;
                CQ[j]+=cell_valueCQ;
                ybmnum[j]++;
            }
        }
    }
    for(int i=0;i<ui->tableWidget->rowCount();i+=4){
        double valnVIC,valnROX,valnFAM,valnCY5C;
        for(int k = 0;k<ybmsame.length();k++){
            if(ui->tableWidget->item(i+1,2)->text()==ybmsame[k]){
                valnVIC=AS[k]/ybmnum[k];
                valnROX=AL[k]/ybmnum[k];
                valnFAM=Y[k]/ybmnum[k];
                valnCY5C=CQ[k]/ybmnum[k];
            }
        }
        //男女浓度比例
        QStringList mwval=mwnd(valnVIC,valnFAM);
        for(int j=0;j<3;j++){
            ui->tableWidget->setItem(i,8+j,new QTableWidgetItem(mwval[j]));
        }
        // 抑制指数降解指数
        QStringList zsjsv=zsjs(valnVIC,valnROX,valnCY5C,valCJ);
        for(int j=0;j<2;j++){
            ui->tableWidget->setItem(i,11+j,new QTableWidgetItem(zsjsv[j]));
        }
        // 建议方案
        QStringList guid = gui(valnROX,valnVIC,valnFAM,valnCY5C,valCJ);
        if(guid.length()==4){
            for(int j=0;j<4;j++){
                ui->tableWidget->setItem(i,13+j,new QTableWidgetItem(guid[j]));
            }
        }else if(guid.length()==5){
            for(int j=0;j<5;j++){
                ui->tableWidget->setItem(i,13+j,new QTableWidgetItem(guid[j]));
            }
        }
    }
    //    numlu();

}

// 男性浓度，女性浓度，男女浓度比例计算
QStringList derivedata::mwnd(double valnVIC,double valnFAM)
{
    QStringList mwval;
    if(valnVIC==0&&valnFAM==0){
        mwval.append("un");
        mwval.append("un");
        mwval.append("-");
    }else if(valnVIC!=0&&valnFAM==0){
        mwval.append("un");
        if(valnVIC<0.003){
            mwval.append("un");
        }else{
            mwval.append(QString::number(valnVIC,'f',4));
        }
        mwval.append("-");
    }else if(valnVIC==0&&valnFAM!=0){
        mwval.append("un");
        mwval.append("un");
        mwval.append("-");
    }else if(valnVIC!=0&&valnFAM!=0){
        if(valnVIC/valnFAM<2){
            mwval.append(QString::number(valnVIC,'f',4));
            mwval.append("un");
            mwval.append("-");
        }else if(valnVIC/valnFAM>=2&&valnVIC>=0.003&&valnVIC<0.02&&valnFAM>0.001){
            mwval.append(QString::number(valnVIC,'f',4));
            mwval.append("un");
            mwval.append("-");
        }else if(valnVIC/valnFAM>=2&&valnVIC>=0.02&&valnFAM>0.001){
            mwval.append(QString::number(valnFAM*1.39,'f',4));
            mwval.append(QString::number(valnVIC-1.39*valnFAM,'f',4));
            mwval.append("1:"+QString::number(valnVIC-1.39*valnFAM/(valnFAM*1.39),'f',2));
        }else{
            mwval.append("-");
            mwval.append("-");
            mwval.append("-");
        }
    }else{
        mwval.append("-");
        mwval.append("-");
        mwval.append("-");
    }
    return mwval;
}

// 抑制指数，降解指数计算
QStringList derivedata::zsjs(double valnVIC, double valnROX, double valnCY5C, double valCJ)
{
    QStringList zs;
    if(valnVIC==0||valnROX==0){
        zs.append("-");
    }else if(valnVIC!=0&&valnROX!=0){
        zs.append(QString::number(valnVIC/valnROX,'f',2));
    }
    zs.append(QString::number(valnCY5C-valCJ,'f',2));
    return zs;
}

// 指导建议及稀释/扩增方案计算
QStringList derivedata::gui(double valnROX,double valnVIC,double valnFAM,double valnCY5C,double valCJ)
{
    QStringList row_data;
    QString path=QCoreApplication::applicationDirPath(); //获取当前项目路径
    QFile file(":/xml/config.xml");//获取文件完整路径
    if(!file.open(QFile::ReadOnly)){//判断文件是否存在
        QMessageBox msgBox;
        msgBox.setText("config.xml文件缺失！");
        msgBox.exec();
    }
    QDomDocument doc;
    QStringList Q;
    QStringList Q41,Q42,Q43,Q44,Q45,Q46,Q47,Q48,Q49,Q50,Q51,Q52,Q53,Q54,Q55,Q56,Q57,Q58,Q59,Q60,Q61,Q62,Q63,Q64,Q65,Q66,Q67,Q68,Q69,Q70,Q71,Q72,Q73,Q74,Q75,Q76,Q77,Q78,Q79,Q80,Q81,Q82,Q83,Q84,Q85,Q86,Q87,Q88,Q89,Q90,Q91,Q92,Q93,Q94,Q95,Q96,Q97,Q98,Q99,Q100,Q101,Q102,Q103,Q104;
    QStringList QQ;
    //设置config.xml到文档
    if(!doc.setContent(&file))
    {
        file.close();
        return {};
    }
    file.close();
    //返回根节点
    QDomElement root=doc.documentElement();
    //获得第一个子节点
    QDomNode node=root.firstChild();
    while(!node.isNull())  //如果节点不空
    {
        if(node.isElement()) //如果节点是元素
        {
            //转换为元素
            QDomElement e=node.toElement();
            QString ICS = e.attribute("ICS");
            QString DI = e.attribute("DI");
            QString ASY = e.attribute("ASY");
            QString DI1 = e.attribute("DI1");
            QString DIN1 = e.attribute("DIN1");
            QString DIN2 = e.attribute("DIN2");
            QString DIN3 = e.attribute("DIN3");
            QString DIN4 = e.attribute("DIN4");
            QString DIN5 = e.attribute("DIN5");
            QString DIN6 = e.attribute("DIN6");
            QString DIN7 = e.attribute("DIN7");
            if (e.tagName()=="value"){
                Q.append(ICS);
                Q.append(DI);
                Q.append(ASY);
                Q.append(DI1);
                Q.append(DIN1);
                Q.append(DIN2);
                Q.append(DIN3);
                Q.append(DIN4);
                Q.append(DIN5);
                Q.append(DIN6);
                Q.append(DIN7);
            }
            QString info1 = e.attribute("info1");
            QString info2 = e.attribute("info2");
            QString info3 = e.attribute("info3");
            QString info4 = e.attribute("info4");
            if (e.tagName()=="k41") {
                Q41.append(info1);
                Q41.append(info2);
                Q41.append(info3);
                Q41.append(info4);
            }else if (e.tagName()=="k42") {
                Q42.append(info1);
                Q42.append(info2);
                Q42.append(info3);
                Q42.append(info4);
            }else if (e.tagName()=="k43") {
                Q43.append(info1);
                Q43.append(info2);
                Q43.append(info3);
                Q43.append(info4);
            }else if (e.tagName()=="k44") {
                Q44.append(info1);
                Q44.append(info2);
                Q44.append(info3);
                Q44.append(info4);
            }else if (e.tagName()=="k45") {
                Q45.append(info1);
                Q45.append(info2);
                Q45.append(info3);
                Q45.append(info4);
            }else if (e.tagName()=="k46") {
                Q46.append(info1);
                Q46.append(info2);
                Q46.append(info3);
                Q46.append(info4);
            }else if (e.tagName()=="k47") {
                Q47.append(info1);
                Q47.append(info2);
                Q47.append(info3);
                Q47.append(info4);
            }else if (e.tagName()=="k48") {
                Q48.append(info1);
                Q48.append(info2);
                Q48.append(info3);
                Q48.append(info4);
            }else if (e.tagName()=="k49") {
                Q49.append(info1);
                Q49.append(info2);
                Q49.append(info3);
                Q49.append(info4);
            }else if (e.tagName()=="k50") {
                Q50.append(info1);
                Q50.append(info2);
                Q50.append(info3);
                Q50.append(info4);
            }else if (e.tagName()=="k51") {
                Q51.append(info1);
                Q51.append(info2);
                Q51.append(info3);
                Q51.append(info4);
            }else if (e.tagName()=="k52") {
                Q52.append(info1);
                Q52.append(info2);
                Q52.append(info3);
                Q52.append(info4);
            }else if (e.tagName()=="k53") {
                Q53.append(info1);
                Q53.append(info2);
                Q53.append(info3);
                Q53.append(info4);
            }else if (e.tagName()=="k54") {
                Q54.append(info1);
                Q54.append(info2);
                Q54.append(info3);
                Q54.append(info4);
            }else if (e.tagName()=="k55") {
                Q55.append(info1);
                Q55.append(info2);
                Q55.append(info3);
                Q55.append(info4);
            }else if (e.tagName()=="k56") {
                Q56.append(info1);
                Q56.append(info2);
                Q56.append(info3);
                Q56.append(info4);
            }else if (e.tagName()=="k57") {
                Q57.append(info1);
                Q57.append(info2);
                Q57.append(info3);
                Q57.append(info4);
            }else if (e.tagName()=="k58") {
                Q58.append(info1);
                Q58.append(info2);
                Q58.append(info3);
                Q58.append(info4);
            }else if (e.tagName()=="k59") {
                Q59.append(info1);
                Q59.append(info2);
                Q59.append(info3);
                Q59.append(info4);
            }else if (e.tagName()=="k60") {
                Q60.append(info1);
                Q60.append(info2);
                Q60.append(info3);
                Q60.append(info4);
            }else if (e.tagName()=="k61") {
                Q61.append(info1);
                Q61.append(info2);
                Q61.append(info3);
                Q61.append(info4);
            }else if (e.tagName()=="k62") {
                Q62.append(info1);
                Q62.append(info2);
                Q62.append(info3);
                Q62.append(info4);
            }else if (e.tagName()=="k63") {
                Q63.append(info1);
                Q63.append(info2);
                Q63.append(info3);
                Q63.append(info4);
            }else if (e.tagName()=="k64") {
                Q64.append(info1);
                Q64.append(info2);
                Q64.append(info3);
                Q64.append(info4);
            }else if (e.tagName()=="k65") {
                Q65.append(info1);
                Q65.append(info2);
                Q65.append(info3);
                Q65.append(info4);
            }else if (e.tagName()=="k66") {
                Q66.append(info1);
                Q66.append(info2);
                Q66.append(info3);
                Q66.append(info4);
            }else if (e.tagName()=="k67") {
                Q67.append(info1);
                Q67.append(info2);
                Q67.append(info3);
                Q67.append(info4);
            }else if (e.tagName()=="k68") {
                Q68.append(info1);
                Q68.append(info2);
                Q68.append(info3);
                Q68.append(info4);
            }else if (e.tagName()=="k69") {
                Q69.append(info1);
                Q69.append(info2);
                Q69.append(info3);
                Q69.append(info4);
            }else if (e.tagName()=="k70") {
                Q70.append(info1);
                Q70.append(info2);
                Q70.append(info3);
                Q70.append(info4);
            }else if (e.tagName()=="k71") {
                Q71.append(info1);
                Q71.append(info2);
                Q71.append(info3);
                Q71.append(info4);
            }else if (e.tagName()=="k72") {
                Q72.append(info1);
                Q72.append(info2);
                Q72.append(info3);
                Q72.append(info4);
            }else if (e.tagName()=="k73") {
                Q73.append(info1);
                Q73.append(info2);
                Q73.append(info3);
                Q73.append(info4);
            }else if (e.tagName()=="k74") {
                Q74.append(info1);
                Q74.append(info2);
                Q74.append(info3);
                Q74.append(info4);
            }else if (e.tagName()=="k75") {
                Q75.append(info1);
                Q75.append(info2);
                Q75.append(info3);
                Q75.append(info4);
            }else if (e.tagName()=="k76") {
                Q76.append(info1);
                Q76.append(info2);
                Q76.append(info3);
                Q76.append(info4);
            }else if (e.tagName()=="k77") {
                Q77.append(info1);
                Q77.append(info2);
                Q77.append(info3);
                Q77.append(info4);
            }else if (e.tagName()=="k78") {
                Q78.append(info1);
                Q78.append(info2);
                Q78.append(info3);
                Q78.append(info4);
            }else if (e.tagName()=="k79") {
                Q79.append(info1);
                Q79.append(info2);
                Q79.append(info3);
                Q79.append(info4);
            }else if (e.tagName()=="k80") {
                Q80.append(info1);
                Q80.append(info2);
                Q80.append(info3);
                Q80.append(info4);
            }else if (e.tagName()=="k81") {
                Q81.append(info1);
                Q81.append(info2);
                Q81.append(info3);
                Q81.append(info4);
            }else if (e.tagName()=="k82") {
                Q82.append(info1);
                Q82.append(info2);
                Q82.append(info3);
                Q82.append(info4);
            }else if (e.tagName()=="k83") {
                Q83.append(info1);
                Q83.append(info2);
                Q83.append(info3);
                Q83.append(info4);
            }else if (e.tagName()=="k84") {
                Q84.append(info1);
                Q84.append(info2);
                Q84.append(info3);
                Q84.append(info4);
            }else if (e.tagName()=="k85") {
                Q85.append(info1);
                Q85.append(info2);
                Q85.append(info3);
                Q85.append(info4);
            }else if (e.tagName()=="k86") {
                Q86.append(info1);
                Q86.append(info2);
                Q86.append(info3);
                Q86.append(info4);
            }else if (e.tagName()=="k87") {
                Q87.append(info1);
                Q87.append(info2);
                Q87.append(info3);
                Q87.append(info4);
            }else if (e.tagName()=="k88") {
                Q88.append(info1);
                Q88.append(info2);
                Q88.append(info3);
                Q88.append(info4);
            }else if (e.tagName()=="k89") {
                Q89.append(info1);
                Q89.append(info2);
                Q89.append(info3);
                Q89.append(info4);
            }else if (e.tagName()=="k90") {
                Q90.append(info1);
                Q90.append(info2);
                Q90.append(info3);
                Q90.append(info4);
            }else if (e.tagName()=="k91") {
                Q91.append(info1);
                Q91.append(info2);
                Q91.append(info3);
                Q91.append(info4);
            }else if (e.tagName()=="k92") {
                Q92.append(info1);
                Q92.append(info2);
                Q92.append(info3);
                Q92.append(info4);
            }else if (e.tagName()=="k93") {
                Q93.append(info1);
                Q93.append(info2);
                Q93.append(info3);
                Q93.append(info4);
            }else if (e.tagName()=="k94") {
                Q94.append(info1);
                Q94.append(info2);
                Q94.append(info3);
                Q94.append(info4);
            }else if (e.tagName()=="k95") {
                Q95.append(info1);
                Q95.append(info2);
                Q95.append(info3);
                Q95.append(info4);
            }else if (e.tagName()=="k96") {
                Q96.append(info1);
                Q96.append(info2);
                Q96.append(info3);
                Q96.append(info4);
            }else if (e.tagName()=="k97") {
                Q97.append(info1);
                Q97.append(info2);
                Q97.append(info3);
                Q97.append(info4);
            }else if (e.tagName()=="k98") {
                Q98.append(info1);
                Q98.append(info2);
                Q98.append(info3);
                Q98.append(info4);
            }else if (e.tagName()=="k99") {
                Q99.append(info1);
                Q99.append(info2);
                Q99.append(info3);
                Q99.append(info4);
            }else if (e.tagName()=="k100") {
                Q100.append(info1);
                Q100.append(info2);
                Q100.append(info3);
                Q100.append(info4);
            }else if (e.tagName()=="k101") {
                Q101.append(info1);
                Q101.append(info2);
                Q101.append(info3);
                Q101.append(info4);
            }else if (e.tagName()=="k102") {
                Q102.append(info1);
                Q102.append(info2);
                Q102.append(info3);
                Q102.append(info4);
            }else if (e.tagName()=="k103") {
                Q103.append(info1);
                Q103.append(info2);
                Q103.append(info3);
                Q103.append(info4);
            }else if (e.tagName()=="k104") {
                Q104.append(info1);
                Q104.append(info2);
                Q104.append(info3);
                Q104.append(info4);
            }

            QDomNodeList list=e.childNodes();
            for(int i=0;i<list.count();i++)
            {
                QDomNode n=list.at(i);
                if(node.isElement())
                    QQ.append(n.toElement().text());
            }
        }
        //下一个兄弟节点
        node=node.nextSibling();
    }
    QString ICSS1 = Q[0];
    double ICS1 = ICSS1.toDouble();
    QString DII1 = Q[1];
    double DI1 = DII1.toDouble();
    QString ASYY1 = Q[2];
    double ASY1 = ASYY1.toDouble();
    QString DII2 = Q[3];
    double DI2 = DII2.toDouble();

    QString DINN1 = Q[4];
    double DIN1 = DINN1.toDouble();
    QString DINN2 = Q[5];
    double DIN2 = DINN2.toDouble();
    QString DINN3 = Q[6];
    double DIN3 = DINN3.toDouble();
    QString DINN4 = Q[7];
    double DIN4 = DINN4.toDouble();
    QString DINN5 = Q[8];
    double DIN5 = DINN5.toDouble();
    QString DINN6 = Q[9];
    double DIN6 = DINN6.toDouble();
    QString DINN7 = Q[10];
    double DIN7 = DINN7.toDouble();

    QString ALL1 = QQ[0];
    double AL1 = ALL1.toDouble();
    QString YY1 = QQ[1];
    double Y1 = YY1.toDouble();
    QString YY2 = QQ[2];
    double Y2 = YY2.toDouble();
    QString ASS1 = QQ[3];
    double AS1 = ASS1.toDouble();
    QString ASS2 = QQ[4];
    double AS2 = ASS2.toDouble();
    QString ASS3 = QQ[5];
    double AS3 = ASS3.toDouble();
    QString ASS4 = QQ[6];
    double AS4 = ASS4.toDouble();
    QString ALL2 = QQ[7];
    double AL2 = ALL2.toDouble();
    QString ALL3 = QQ[8];
    double AL3 = ALL3.toDouble();
    QString ALL4 = QQ[9];
    double AL4 = ALL4.toDouble();
    QString ALL5 = QQ[10];
    double AL5 = ALL5.toDouble();
    QString ASS5 = QQ[11];
    double AS5 = ASS5.toDouble();
    QString ASS6 = QQ[12];
    double AS6 = ASS6.toDouble();
    QString ASS7 = QQ[13];
    double AS7 = ASS7.toDouble();
    QString ASS8 = QQ[14];
    double AS8 = ASS8.toDouble();
    QString ASS9 = QQ[15];
    double AS9 = ASS9.toDouble();
    QString YY3 = QQ[16];
    double Y3 = YY3.toDouble();
    QString YY4 = QQ[17];
    double Y4 = YY4.toDouble();
    QString YY5 = QQ[18];
    double Y5 = YY5.toDouble();
    QString YY6 = QQ[19];
    double Y6 = YY6.toDouble();
    QString ALL6 = QQ[20];
    double AL6 = ALL6.toDouble();

    QString ALNN1 = QQ[21];
    double ALN1 = ALNN1.toDouble();
    QString ALNN2 = QQ[22];
    double ALN2 = ALNN2.toDouble();
    QString ALNN3 = QQ[23];
    double ALN3 = ALNN3.toDouble();
    QString ALNN4 = QQ[24];
    double ALN4 = ALNN4.toDouble();
    QString ALNN5 = QQ[25];
    double ALN5 = ALNN5.toDouble();
    QString ALNN6 = QQ[26];
    double ALN6 = ALNN6.toDouble();

    QString ALNN7 = QQ[27];
    double ALN7 = ALNN7.toDouble();
    QString ALNN8 = QQ[28];
    double ALN8 = ALNN8.toDouble();
    QString ALNN9 = QQ[29];
    double ALN9 = ALNN9.toDouble();
    QString ALNN10 = QQ[30];
    double ALN10 = ALNN10.toDouble();
    QString ALNN11 = QQ[31];
    double ALN11 = ALNN11.toDouble();
    QString ALNN12 = QQ[32];
    double ALN12 = ALNN12.toDouble();

    QString ALNN13 = QQ[33];
    double ALN13 = ALNN13.toDouble();
    QString ALNN14 = QQ[34];
    double ALN14 = ALNN14.toDouble();
    QString ALNN15 = QQ[35];
    double ALN15 = ALNN15.toDouble();
    QString ALNN16 = QQ[36];
    double ALN16 = ALNN16.toDouble();
    QString ALNN17 = QQ[37];
    double ALN17 = ALNN17.toDouble();
    QString ALNN18 = QQ[38];
    double ALN18 = ALNN18.toDouble();

    QString ALNN19 = QQ[39];
    double ALN19 = ALNN19.toDouble();
    QString ALNN20 = QQ[40];
    double ALN20 = ALNN20.toDouble();
    QString ALNN21 = QQ[41];
    double ALN21 = ALNN21.toDouble();
    QString ALNN22 = QQ[42];
    double ALN22 = ALNN22.toDouble();
    QString ALNN23 = QQ[43];
    double ALN23 = ALNN23.toDouble();
    QString ALNN24 = QQ[44];
    double ALN24 = ALNN24.toDouble();

    QString ASNN1 = QQ[45];
    double ASN1 = ASNN1.toDouble();
    QString ASNN2 = QQ[46];
    double ASN2 = ASNN2.toDouble();
    QString ASNN3 = QQ[47];
    double ASN3 = ASNN3.toDouble();
    QString ASNN4 = QQ[48];
    double ASN4 = ASNN4.toDouble();
    QString ASNN5 = QQ[49];
    double ASN5 = ASNN5.toDouble();
    QString ASNN6 = QQ[50];
    double ASN6 = ASNN6.toDouble();
    QString ASNN7 = QQ[51];
    double ASN7 = ASNN7.toDouble();

    QString ASNN8 = QQ[52];
    double ASN8 = ASNN8.toDouble();
    QString ASNN9 = QQ[53];
    double ASN9 = ASNN9.toDouble();
    QString ASNN10 = QQ[54];
    double ASN10 = ASNN10.toDouble();
    QString ASNN11 = QQ[55];
    double ASN11 = ASNN11.toDouble();
    QString ASNN12 = QQ[56];
    double ASN12 = ASNN12.toDouble();

    QString ALNN25 = QQ[57];
    double ALN25 = ALNN25.toDouble();
    QString ALNN26 = QQ[58];
    double ALN26 = ALNN26.toDouble();
    QString ALNN27 = QQ[59];
    double ALN27 = ALNN27.toDouble();
    QString ALNN28 = QQ[60];
    double ALN28 = ALNN28.toDouble();
    QString ALNN29 = QQ[61];
    double ALN29 = ALNN29.toDouble();
    QString ALNN30 = QQ[62];
    double ALN30 = ALNN30.toDouble();

    QString YNN1 = QQ[63];
    double YN1 = YNN1.toDouble();
    QString YNN2 = QQ[64];
    double YN2 = YNN2.toDouble();
    QString YNN3 = QQ[65];
    double YN3 = YNN3.toDouble();
    QString YNN4 = QQ[66];
    double YN4 = YNN4.toDouble();
    QString YNN5 = QQ[67];
    double YN5 = YNN5.toDouble();

    if(valnROX!=0&&valnVIC!=0){
        int xY = qRound(5*(valnFAM/0.5)-5);
        QString XY = QString::number(xY);
        int xY2 = qRound(5*(valnFAM/0.8)-5);
        QString XY2 = QString::number(xY2);
        int xAS1 = qRound(5*(valnVIC/0.5)-5);
        QString XAS1 = QString::number(xAS1);
        int xAS2 = qRound(5*(valnVIC/0.4)-5);
        QString XAS2 = QString::number(xAS2);
        int xAL1 = qRound(5*(valnROX/0.16)-5);
        QString XAL1 = QString::number(xAL1);
        int xAL2 = qRound(5*(valnROX/0.1)-5);
        QString XAL2 = QString::number(xAL2);
        int xAL3 = qRound(5*(valnROX/0.06)-5);
        QString XAL3 = QString::number(xAL3);
        int xAL4 = qRound(5*(valnROX/0.05)-5);
        QString XAL4 = QString::number(xAL4);
        int xAL5 = qRound(5*(valnROX/0.02)-5);
        QString XAL5 = QString::number(xAL5);

        if(valnVIC/valnROX<DIN1&&valnVIC/valnFAM>ASY1&&valnVIC>AS3&&valnFAM>Y3){
            if(valnFAM>Y3&&valnFAM<Y4){
                row_data<<Q41[1]<<Q41[2]<<Q41[3]<<Q41[0]<<"可能为男女混合样";
            }else if(valnFAM>Y4&&valnFAM<Y5){
                row_data<<Q42[1]<<Q42[2]<<Q42[3]<<Q42[0]<<"可能为男女混合样";
            }else if(valnFAM>Y5&&valnFAM<Y6){
                row_data<<Q43[1]<<Q43[2]<<Q43[3]<<Q43[0]<<"可能为男女混合样";
            }else if(valnFAM>Y6){
                row_data<<Q44[1]<<Q44[2]<<XY+"ul"<<Q44[0]<<"可能为男女混合样";
            }
        }else if(valnVIC/valnROX>DIN1&&valnVIC/valnROX<DIN7&&valnVIC/valnFAM>=ASY1&&valnFAM>=YN1){
            if(valnFAM>=YN1&&valnFAM<YN2){
                row_data<<Q100[1]<<Q100[2]<<Q100[3]<<Q100[0]<<"可能为男女混合样";
            }else if(valnFAM>=YN2&&valnFAM<YN3){
                row_data<<Q101[1]<<Q101[2]<<Q101[3]<<Q101[0]<<"可能为男女混合样";
            }else if(valnFAM>=YN3&&valnFAM<YN4){
                row_data<<Q102[1]<<Q102[2]<<Q102[3]<<Q102[0]<<"可能为男女混合样";
            }else if(valnFAM>=YN4&&valnFAM<YN5){
                row_data<<Q103[1]<<Q103[2]<<Q103[3]<<Q103[0]<<"可能为男女混合样";
            }else if(valnFAM>=YN5){
                row_data<<Q104[1]<<Q104[2]<<XY2+"ul"<<Q104[0]<<"可能为男女混合样";
            }
        }else if(valnCY5C-valCJ<ICS1&&valnVIC/valnROX<DIN1){
            if(valnVIC<ASN1){
                row_data<<Q46[1]<<Q46[2]<<Q46[3]<<Q46[0];
            }else if(valnVIC>=ASN1&&valnVIC<=ASN2){
                row_data<<Q47[1]<<Q47[2]<<Q47[3]<<Q47[0];
            }else if(valnVIC>ASN2&&valnVIC<=ASN3){
                row_data<<Q48[1]<<Q48[2]<<Q48[3]<<Q48[0];
            }else if(valnVIC>ASN3&&valnVIC<=ASN4){
                row_data<<Q49[1]<<Q49[2]<<Q49[3]<<Q49[0];
            }else if(valnVIC>ASN4&&valnVIC<=ASN5){
                row_data<<Q50[1]<<Q50[2]<<Q50[3]<<Q50[0];
            }else if(valnVIC>ASN5&&valnVIC<=ASN6){
                row_data<<Q51[1]<<Q51[2]<<Q51[3]<<Q51[0];
            }else if(valnVIC>ASN6){
                row_data<<Q52[1]<<Q52[2]<<XAS2+"ul"<<Q52[0];
            }
        }else if(valnCY5C-valCJ<ICS1&&valnVIC/valnROX>=DIN1&&valnVIC/valnROX<=DIN2){
            if(valnROX<ALN1&&valnVIC<ASN7){
                row_data<<Q53[1]<<Q53[2]<<Q53[3]<<Q53[0];
            }else if(valnROX<ALN1&&valnVIC>=ASN7){
                if(valnVIC>=ASN8&&valnVIC<=ASN9){
                    row_data<<Q87[1]<<Q87[2]<<Q87[3]<<Q87[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN9&&valnVIC<=ASN10){
                    row_data<<Q88[1]<<Q88[2]<<Q88[3]<<Q88[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN10&&valnVIC<=ASN11){
                    row_data<<Q89[1]<<Q89[2]<<Q89[3]<<Q89[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN11&&valnVIC<=ASN12){
                    row_data<<Q90[1]<<Q90[2]<<Q90[3]<<Q90[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN12){
                    row_data<<Q91[1]<<Q91[2]<<XAS1+"ul"<<Q91[0]<<"二代测序上样方案见相应分表";
                }
            }else if(valnROX>=ALN1&&valnROX<=ALN2){
                row_data<<Q55[1]<<Q55[2]<<Q55[3]<<Q55[0];
            }else if(valnROX>ALN2&&valnROX<=ALN3){
                row_data<<Q56[1]<<Q56[2]<<Q56[3]<<Q56[0];
            }else if(valnROX>ALN3&&valnROX<=ALN4){
                row_data<<Q57[1]<<Q57[2]<<Q57[3]<<Q57[0];
            }else if(valnROX>ALN4&&valnROX<=ALN5){
                row_data<<Q58[1]<<Q58[2]<<Q58[3]<<Q58[0];
            }else if(valnROX>ALN5&&valnROX<=ALN6){
                row_data<<Q59[1]<<Q59[2]<<Q59[3]<<Q59[0];
            }else if(valnROX>ALN6){
                row_data<<Q60[1]<<Q60[2]<<XAL1+"ul"<<Q60[0];
            }
        }else if(valnCY5C-valCJ<ICS1&&valnVIC/valnROX>DIN2&&valnVIC/valnROX<=DIN3){
            if(valnROX<ALN7&&valnVIC<ASN7){
                row_data<<Q61[1]<<Q61[2]<<Q61[3]<<Q61[0];
            }else if(valnROX<ALN7&&valnVIC>=ASN7){
                if(valnVIC>=ASN8&&valnVIC<=ASN9){
                    row_data<<Q87[1]<<Q87[2]<<Q87[3]<<Q87[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN9&&valnVIC<=ASN10){
                    row_data<<Q88[1]<<Q88[2]<<Q88[3]<<Q88[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN10&&valnVIC<=ASN11){
                    row_data<<Q89[1]<<Q89[2]<<Q89[3]<<Q89[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN11&&valnVIC<=ASN12){
                    row_data<<Q90[1]<<Q90[2]<<Q90[3]<<Q90[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN12){
                    row_data<<Q91[1]<<Q91[2]<<XAS1+"ul"<<Q91[0]<<"二代测序上样方案见相应分表";
                }
            }else if(valnROX>=ALN7&&valnROX<=ALN8){
                row_data<<Q63[1]<<Q63[2]<<Q63[3]<<Q63[0];
            }else if(valnROX>ALN8&&valnROX<=ALN9){
                row_data<<Q64[1]<<Q64[2]<<Q64[3]<<Q64[0];
            }else if(valnROX>ALN9&&valnROX<=ALN10){
                row_data<<Q65[1]<<Q65[2]<<Q65[3]<<Q65[0];
            }else if(valnROX>ALN10&&valnROX<=ALN11){
                row_data<<Q66[1]<<Q66[2]<<Q66[3]<<Q66[0];
            }else if(valnROX>ALN11&&valnROX<=ALN12){
                row_data<<Q67[1]<<Q67[2]<<Q67[3]<<Q67[0];
            }else if(valnROX>ALN12){
                row_data<<Q68[1]<<Q68[2]<<XAL2+"ul"<<Q68[0];
            }
        }else if(valnCY5C-valCJ<ICS1&&valnVIC/valnROX>DIN3&&valnVIC/valnROX<=DIN4){
            if(valnROX<ALN13&&valnVIC<ASN7){
                row_data<<Q69[1]<<Q69[2]<<Q69[3]<<Q69[0];
            }else if(valnROX<ALN13&&valnVIC>=ASN7){
                if(valnVIC>=ASN8&&valnVIC<=ASN9){
                    row_data<<Q87[1]<<Q87[2]<<Q87[3]<<Q87[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN9&&valnVIC<=ASN10){
                    row_data<<Q88[1]<<Q88[2]<<Q88[3]<<Q88[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN10&&valnVIC<=ASN11){
                    row_data<<Q89[1]<<Q89[2]<<Q89[3]<<Q89[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN11&&valnVIC<=ASN12){
                    row_data<<Q90[1]<<Q90[2]<<Q90[3]<<Q90[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN12){
                    row_data<<Q91[1]<<Q91[2]<<XAS1+"ul"<<Q91[0]<<"二代测序上样方案见相应分表";
                }
            }else if(valnROX>=ALN13&&valnROX<=ALN14){
                row_data<<Q71[1]<<Q71[2]<<Q71[3]<<Q71[0];
            }else if(valnROX>ALN14&&valnROX<=ALN15){
                row_data<<Q72[1]<<Q72[2]<<Q72[3]<<Q72[0];
            }else if(valnROX>ALN15&&valnROX<=ALN16){
                row_data<<Q73[1]<<Q73[2]<<Q73[3]<<Q73[0];
            }else if(valnROX>ALN16&&valnROX<=ALN17){
                row_data<<Q74[1]<<Q74[2]<<Q74[3]<<Q74[0];
            }else if(valnROX>ALN17&&valnROX<=ALN18){
                row_data<<Q75[1]<<Q75[2]<<Q75[3]<<Q75[0];
            }else if(valnROX>ALN18){
                row_data<<Q76[1]<<Q76[2]<<XAL3+"ul"<<Q76[0];
            }
        }else if(valnCY5C-valCJ<ICS1&&valnVIC/valnROX>DIN4&&valnVIC/valnROX<=DIN5){
            if(valnROX<ALN19&&valnVIC<ASN7){
                row_data<<Q77[1]<<Q77[2]<<Q77[3]<<Q77[0];
            }else if(valnROX<ALN19&&valnVIC>=ASN7){
                if(valnVIC>=ASN8&&valnVIC<=ASN9){
                    row_data<<Q87[1]<<Q87[2]<<Q87[3]<<Q87[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN9&&valnVIC<=ASN10){
                    row_data<<Q88[1]<<Q88[2]<<Q88[3]<<Q88[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN10&&valnVIC<=ASN11){
                    row_data<<Q89[1]<<Q89[2]<<Q89[3]<<Q89[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN11&&valnVIC<=ASN12){
                    row_data<<Q90[1]<<Q90[2]<<Q90[3]<<Q90[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN12){
                    row_data<<Q91[1]<<Q91[2]<<XAS1+"ul"<<Q91[0]<<"二代测序上样方案见相应分表";
                }
            }else if(valnROX>=ALN19&&valnROX<=ALN20){
                row_data<<Q79[1]<<Q79[2]<<Q79[3]<<Q79[0];
            }else if(valnROX>ALN20&&valnROX<=ALN21){
                row_data<<Q80[1]<<Q80[2]<<Q80[3]<<Q80[0];
            }else if(valnROX>ALN21&&valnROX<=ALN22){
                row_data<<Q81[1]<<Q81[2]<<Q81[3]<<Q81[0];
            }else if(valnROX>ALN22&&valnROX<=ALN23){
                row_data<<Q82[1]<<Q82[2]<<Q82[3]<<Q82[0];
            }else if(valnROX>ALN23&&valnROX<=ALN24){
                row_data<<Q83[1]<<Q83[2]<<Q83[3]<<Q83[0];
            }else if(valnROX>ALN24){
                row_data<<Q84[1]<<Q84[2]<<XAL4+"ul"<<Q84[0];
            }
        }else if(valnCY5C-valCJ<ICS1&&valnVIC/valnROX>DIN5&&valnVIC/valnROX<=DIN6){
            if(valnROX<ALN25&&valnVIC<ASN7){
                row_data<<Q92[1]<<Q92[2]<<Q92[3]<<Q92[0];
            }else if(valnROX<ALN25&&valnVIC>=ASN7){
                if(valnVIC>=ASN8&&valnVIC<=ASN9){
                    row_data<<Q87[1]<<Q87[2]<<Q87[3]<<Q87[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN9&&valnVIC<=ASN10){
                    row_data<<Q88[1]<<Q88[2]<<Q88[3]<<Q88[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN10&&valnVIC<=ASN11){
                    row_data<<Q89[1]<<Q89[2]<<Q89[3]<<Q89[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN11&&valnVIC<=ASN12){
                    row_data<<Q90[1]<<Q90[2]<<Q90[3]<<Q90[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN12){
                    row_data<<Q91[1]<<Q91[2]<<XAS1+"ul"<<Q91[0]<<"二代测序上样方案见相应分表";
                }
            }else if(valnROX>=ALN25&&valnROX<=ALN26){
                row_data<<Q94[1]<<Q94[2]<<Q94[3]<<Q94[0];
            }else if(valnROX>ALN26&&valnROX<=ALN27){
                row_data<<Q95[1]<<Q95[2]<<Q95[3]<<Q95[0];
            }else if(valnROX>ALN27&&valnROX<=ALN28){
                row_data<<Q96[1]<<Q96[2]<<Q96[3]<<Q96[0];
            }else if(valnROX>ALN28&&valnROX<=ALN29){
                row_data<<Q97[1]<<Q97[2]<<Q97[3]<<Q97[0];
            }else if(valnROX>ALN29&&valnROX<=ALN30){
                row_data<<Q98[1]<<Q98[2]<<Q98[3]<<Q98[0];
            }else if(valnROX>ALN30){
                row_data<<Q99[1]<<Q99[2]<<XAL5+"ul"<<Q99[0];
            }
        }else if(valnCY5C-valCJ<ICS1&&(valnVIC/valnROX>DIN6||valnVIC/valnROX==0)){
            if(valnVIC<ASN7){
                row_data<<Q85[1]<<Q85[2]<<Q85[3]<<Q85[0];
            }else if(valnVIC>=ASN7){
                if(valnVIC>=ASN8&&valnVIC<=ASN9){
                    row_data<<Q87[1]<<Q87[2]<<Q87[3]<<Q87[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN9&&valnVIC<=ASN10){
                    row_data<<Q88[1]<<Q88[2]<<Q88[3]<<Q88[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN10&&valnVIC<=ASN11){
                    row_data<<Q89[1]<<Q89[2]<<Q89[3]<<Q89[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN11&&valnVIC<=ASN12){
                    row_data<<Q90[1]<<Q90[2]<<Q90[3]<<Q90[0]<<"二代测序上样方案见相应分表";
                }else if(valnVIC>ASN12){
                    row_data<<Q91[1]<<Q91[2]<<XAS1+"ul"<<Q91[0]<<"二代测序上样方案见相应分表";
                }
            }
        }else if(valnCY5C-valCJ>=ICS1){
            row_data<<Q45[1]<<Q45[2]<<Q45[3]<<Q45[0];
        }else{
            row_data<<"-"<<"-"<<"-"<<"-";
        }
    }else{
        int xAS1 = qRound(5*(valnVIC/0.5)-5);
        QString XAS1 = QString::number(xAS1);
        if(valnVIC<ASN7){
            row_data<<Q85[1]<<Q85[2]<<Q85[3]<<Q85[0];
        }else if(valnVIC>=ASN7){
            if(valnVIC>=ASN8&&valnVIC<=ASN9){
                row_data<<Q87[1]<<Q87[2]<<Q87[3]<<Q87[0]<<"二代测序上样方案见相应分表";
            }else if(valnVIC>ASN9&&valnVIC<=ASN10){
                row_data<<Q88[1]<<Q88[2]<<Q88[3]<<Q88[0]<<"二代测序上样方案见相应分表";
            }else if(valnVIC>ASN10&&valnVIC<=ASN11){
                row_data<<Q89[1]<<Q89[2]<<Q89[3]<<Q89[0]<<"二代测序上样方案见相应分表";
            }else if(valnVIC>ASN11&&valnVIC<=ASN12){
                row_data<<Q90[1]<<Q90[2]<<Q90[3]<<Q90[0]<<"二代测序上样方案见相应分表";
            }else if(valnVIC>ASN12){
                row_data<<Q91[1]<<Q91[2]<<XAS1+"ul"<<Q91[0]<<"二代测序上样方案见相应分表";
            }
        }
    }
    return row_data;
}

// 下游加样表格导出 cnr 6.22
void derivedata::datao()
{
    // 检查目录是否存在，如果不存在则创建
    QDir dir;
    if (!dir.exists("./dataout/")) {
        dir.mkpath("./dataout/"); // 创建目录，包括所有必要的上级目录
    }
    QString valna;
    QStringList konglist;
    char col = 'A';
    int row = 1;
    for(col='A';col<='H';col++){
        row=1;
        for(row;row<=12;row++){
            QString element = QString("%1%2").arg(col).arg(row);
            konglist.append(element);
        }
    }
    if(ui->tableWidget->verticalHeader()->count()){
        // 创建一个新的Excel文档
        QXlsx::Document xlsx;

        // 获取当前时间并转换为字符串
        QString currentTime = QDateTime::currentDateTime().toString("yyyy-MM-dd_HH-mm-ss");
        QString fileName = currentTime + "_test.xlsx";
        QString fileName2 = currentTime + "_test.csv";
        QString fullPath3 = "./dataout/" + currentTime + "_test.txt";
        QString fullPath4;
        if(doutfl!=1){
            QDir dir;
            if (!dir.exists(filep)) {
                dir.mkpath(filep); // 创建目录，包括所有必要的上级目录
            }
            QString directory1 = filep;
            fullPath4 = directory1 + "/"+currentTime + "_test.txt";
        }else if(doutfl==1){
            QDir dir;
            if (!dir.exists(outpath)) {
                dir.mkpath(outpath); // 创建目录，包括所有必要的上级目录
            }
            QString directory1 = outpath;
            fullPath4 = directory1 + "/"+currentTime + "_test.txt";
        }
        QFile file(fullPath3);
        QFile file2(fullPath4);
        if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
            // 处理文件打开失败的情况
            QMessageBox::critical(nullptr, "Error", "Could not open file for writing:" + file.errorString());
            return;
        }
        if (!file2.open(QIODevice::WriteOnly | QIODevice::Text)) {
            // 处理文件打开失败的情况
            QMessageBox::critical(nullptr, "Error", "Could not open file for writing:" + file2.errorString());
            return;
        }
        QTextStream out(&file);
        QTextStream out2(&file2);
        // 设置编码，如果需要的话，比如UTF-8
        out.setCodec("UTF-8");
        out2.setCodec("UTF-8");

        // 添加5个sheet页
        xlsx.addSheet("样本设置");
        xlsx.addSheet("原始数据");
        xlsx.addSheet("扩增数据");
        xlsx.addSheet("结果分析");
        xlsx.addSheet("下游加样表格");
        QString sql="SELECT ExperimentName,RunTime,FinishTime FROM ExperimentInfo";
        QSqlDatabase db = dbHelper::openConnection();
        QSqlQuery query(db);
        QStringList sanames;
        query.exec(sql);
        while (query.next()) {
            QString column1Value = query.value("ExperimentName").toString();
            QString column2Value = query.value("RunTime").toString();
            QString column3Value = query.value("FinishTime").toString();
            sanames.append(column1Value);
            sanames.append(column2Value);
            sanames.append(column3Value);
        }
        if(true){
            out<<QString("样本设置\n");
            out<<QString("仪器名称\t")<<QString("RT-PCR-96\n");
            out<<QString("创建日期\t")<<QString(sanames[1]+"\n");
            out<<QString("实验名称\t")<<QString(sanames[0]+"\n");
            out<<QString("实验结束时间\t")<<QString(sanames[2]+"\n");
            out2<<QString("样本设置\n");
            out2<<QString("仪器名称\t")<<QString("RT-PCR-96\n");
            out2<<QString("创建日期\t")<<QString(sanames[1]+"\n");
            out2<<QString("实验名称\t")<<QString(sanames[0]+"\n");
            out2<<QString("实验结束时间\t")<<QString(sanames[2]+"\n");
            xlsx.selectSheet("样本设置");
            xlsx.write(1,1,"仪器名称");
            xlsx.write(2,1,"创建日期");
            xlsx.write(3,1,"实验名称");
            xlsx.write(4,1,"实验结束时间");
            xlsx.write(1,2,"RT-PCR-96");
            xlsx.write(2,2,sanames[1]);
            xlsx.write(3,2,sanames[0]);
            xlsx.write(4,2,sanames[2]);
            QStringList tit;
            tit<<"编号"<<"孔位"<<"样本名称"<<"样本类型"<<"荧光染料"<<"数量";
            out<<QString("编号\t")<<QString("孔位\t")<<QString("样本名称\t")<<QString("样本类型\t")<<QString("荧光染料\t")<<QString("数量\t");
            out2<<QString("编号\t")<<QString("孔位\t")<<QString("样本名称\t")<<QString("样本类型\t")<<QString("荧光染料\t")<<QString("数量\t");
            for(int i=0;i<tit.length();i++){
                xlsx.write(6,i+1,tit[i]);
            }
            int num=7;
            bool flin;
            QStringList rowdata;
            for(int i=0;i<96;i++){
                flin=false;
                for(int j=0;j<ui->tableWidget->rowCount();j++){
                    if(konglist[i]==ui->tableWidget->item(j,1)->text()){
                        rowdata<<QString::number(i+1)<<konglist[i]<<ui->tableWidget->item(j+2,1)->text()<<"Target 1"<<"RGB(255,128,0)"<<ui->tableWidget->item(j+2,2)->text()<<ui->tableWidget->item(j+2,4)->text();
                        if(ui->tableWidget->item(j,2)->text()=="标准品"){
                            rowdata<<ui->tableWidget->item(j+2,6)->text();
                        }
                        for(int c=0;c<rowdata.length();c++){
                            xlsx.write(num,c+1,rowdata[c]);
                            out<<rowdata[c]<<"\t";
                            out2<<rowdata[c]<<"\t";
                        }
                        num++;
                        rowdata.clear();
                        rowdata<<QString::number(i+1)<<konglist[i]<<ui->tableWidget->item(j+3,1)->text()<<"Target 2"<<"RGB(255,255,0)"<<ui->tableWidget->item(j+3,2)->text()<<ui->tableWidget->item(j+3,4)->text();
                        if(ui->tableWidget->item(j,2)->text()=="标准品"){
                            rowdata<<ui->tableWidget->item(j+3,6)->text();
                        }
                        for(int c=0;c<rowdata.length();c++){
                            xlsx.write(num,c+1,rowdata[c]);
                            out<<rowdata[c]<<"\t";
                            out2<<rowdata[c]<<"\t";
                        }
                        num++;
                        rowdata.clear();
                        rowdata<<QString::number(i+1)<<konglist[i]<<ui->tableWidget->item(j+1,1)->text()<<"Target 3"<<"RGB(0,139,69)"<<ui->tableWidget->item(j+1,2)->text()<<ui->tableWidget->item(j+1,4)->text();
                        if(ui->tableWidget->item(j,2)->text()=="标准品"){
                            rowdata<<ui->tableWidget->item(j+1,6)->text();
                        }
                        for(int c=0;c<rowdata.length();c++){
                            xlsx.write(num,c+1,rowdata[c]);
                            out<<rowdata[c]<<"\t";
                            out2<<rowdata[c]<<"\t";
                        }
                        num++;
                        rowdata.clear();
                        rowdata<<QString::number(i+1)<<konglist[i]<<ui->tableWidget->item(j,1)->text()<<"Target 4"<<"RGB(255,0,0)"<<ui->tableWidget->item(j,2)->text()<<ui->tableWidget->item(j,4)->text();
                        if(ui->tableWidget->item(j,2)->text()=="标准品"){
                            rowdata<<ui->tableWidget->item(j,6)->text();
                        }
                        for(int c=0;c<rowdata.length();c++){
                            xlsx.write(num,c+1,rowdata[c]);
                            out<<rowdata[c]<<"\t";
                            out2<<rowdata[c]<<"\t";
                        }
                        num++;
                        rowdata.clear();
                        out<<"\n";
                        out2<<"\n";
                        flin=true;
                        break;
                    }
                }
                if(!flin){
                    rowdata<<QString::number(i+1)<<konglist[i];
                    for(int c=0;c<rowdata.length();c++){
                        xlsx.write(num,c+1,rowdata[c]);
                        out<<rowdata[c]<<"\t";
                        out2<<rowdata[c]<<"\t";
                    }
                    num++;
                    rowdata.clear();
                    out<<",\n";
                    out2<<",\n";
                }
            }
        }
        if(true){
            xlsx.selectSheet("原始数据");
            out<<"\n"<<"\n"<<"\n"<<"\n"<<"\n";
            out2<<"\n"<<"\n"<<"\n"<<"\n"<<"\n";
            out<<QString("原始数据\n");
            out2<<QString("原始数据\n");
            QStringList tit;
            tit<<"样本孔位"<<"循环数"<<"FAM"<<"VIC"<<"ROX"<<"CY5";
            out<<QString("样本孔位\t")<<QString("循环数\t")<<QString("FAM\t")<<QString("VIC\t")<<QString("ROX\t")<<QString("CY5\n");
            out2<<QString("样本孔位\t")<<QString("循环数\t")<<QString("FAM\t")<<QString("VIC\t")<<QString("ROX\t")<<QString("CY5\n");
            for(int i=0;i<tit.length();i++){
                xlsx.write(1,i+1,tit[i]);
            }
            int xh = xhval;
            for(int j=0;j<xh;j++){
                for(int i=0;i<konglist.length();i++){
                    xlsx.write(j*96+i+2,1,konglist[i]);
                    xlsx.write(j*96+i+2,2,QString::number(j+1));
                }
            }

            QSqlDatabase db = dbHelper::openConnection();
            QSqlQuery query(db);

            QString sql="SELECT PositionNumber,CyclesNumber,FAM,VIC,ROX,CY5 FROM FluorescenceData";
            query.exec(sql);
            QStringList kongw,xhs,famData,vicData,roxData,cy5Data;
            while (query.next()) {
                kongw.append(query.value("PositionNumber").toString());
                xhs.append(query.value("CyclesNumber").toString());
                famData.append(query.value("FAM").toString());
                vicData.append(query.value("VIC").toString());
                roxData.append(query.value("ROX").toString());
                cy5Data.append(query.value("CY5").toString());
            }

            QStringList bz96;
            for(int j=0;j<xh;j++){
                for(int i=1;i<97;i++){
                    bz96.append(QString::number(i));
                }
            }

            int flk=0,flh=0;
            for(int i=0;i<xh;i++){
                for(int j=0;j<96;j++){
                    if(bz96[96*i+j]==kongw[flk]){
                        out<<konglist[j]<<"\t"<<QString::number(i+1)<<"\t"<<famData[flk]<<"\t"<<vicData[flk]<<"\t"<<roxData[flk]<<"\t"<<cy5Data[flk]<<"\n";
                        out2<<konglist[j]<<"\t"<<QString::number(i+1)<<"\t"<<famData[flk]<<"\t"<<vicData[flk]<<"\t"<<roxData[flk]<<"\t"<<cy5Data[flk]<<"\n";
                        xlsx.write(flh+2,3,famData[flk].toInt());
                        xlsx.write(flh+2,4,vicData[flk].toInt());
                        xlsx.write(flh+2,5,roxData[flk].toInt());
                        xlsx.write(flh+2,6,cy5Data[flk].toInt());
                        if(flk==kongw.length()-1){

                        }else{
                            flk++;
                        }
                        flh++;
                    }else{
                        out<<konglist[j]<<"\t"<<QString::number(i+1)<<"\t"<<" "<<"\t"<<" "<<"\t"<<" "<<"\t"<<" "<<"\n";
                        out2<<konglist[j]<<"\t"<<QString::number(i+1)<<"\t"<<" "<<"\t"<<" "<<"\t"<<" "<<"\t"<<" "<<"\n";
                        xlsx.write(flh+2,3,"");
                        xlsx.write(flh+2,4,"");
                        xlsx.write(flh+2,5,"");
                        xlsx.write(flh+2,6,"");
                        flh++;
                    }
                }
            }
        }
        if(true){
            xlsx.selectSheet("扩增数据");
            out<<"\n"<<"\n"<<"\n"<<"\n"<<"\n";
            out2<<"\n"<<"\n"<<"\n"<<"\n"<<"\n";
            out<<QString("扩增数据\n");
            out2<<QString("扩增数据\n");
            QStringList tit;
            tit<<"编号"<<"样本孔位"<<"循环数"<<"通道名称"<<"Rn"<<"ΔRn";
            out<<QString("编号\t")<<QString("样本孔位\t")<<QString("循环数\t")<<QString("通道名称\t")<<QString("Rn\t")<<QString("ΔRn\n");
            out2<<QString("编号\t")<<QString("样本孔位\t")<<QString("循环数\t")<<QString("通道名称\t")<<QString("Rn\t")<<QString("ΔRn\n");
            for(int i=0;i<tit.length();i++){
                xlsx.write(1,i+1,tit[i]);
            }
            int xh=xhval;
            int flh=2;
            QStringList famrn,vicrn,roxrn,cy5rn;
            if(true){
                QString sql = QString("SELECT BaselineValue FROM FluorescenceResultTable WHERE AccessType='FAM'");
                QSqlDatabase db = dbHelper::openConnection();
                QSqlQuery query(db);
                if (!query.exec(sql)) {
                    qDebug() << "Query failed:" << query.lastError().text();
                    return; // 或者其他错误处理
                }
                while (query.next()) {
                    famrn.append( query.value("BaselineValue").toString());
                }
            }
            if(true){
                QString sql = QString("SELECT BaselineValue FROM FluorescenceResultTable WHERE AccessType='VIC'");
                QSqlDatabase db = dbHelper::openConnection();
                QSqlQuery query(db);
                if (!query.exec(sql)) {
                    qDebug() << "Query failed:" << query.lastError().text();
                    return; // 或者其他错误处理
                }
                while (query.next()) {
                    vicrn.append( query.value("BaselineValue").toString());
                }
            }
            if(true){
                QString sql = QString("SELECT BaselineValue FROM FluorescenceResultTable WHERE AccessType='ROX'");
                QSqlDatabase db = dbHelper::openConnection();
                QSqlQuery query(db);
                if (!query.exec(sql)) {
                    qDebug() << "Query failed:" << query.lastError().text();
                    return; // 或者其他错误处理
                }
                while (query.next()) {
                    roxrn.append( query.value("BaselineValue").toString());
                }
            }
            if(true){
                QString sql = QString("SELECT BaselineValue FROM FluorescenceResultTable WHERE AccessType='CY5'");
                QSqlDatabase db = dbHelper::openConnection();
                QSqlQuery query(db);
                if (!query.exec(sql)) {
                    qDebug() << "Query failed:" << query.lastError().text();
                    return; // 或者其他错误处理
                }
                while (query.next()) {
                    cy5rn.append( query.value("BaselineValue").toString());
                }
            }
            for(int i=0;i<96;i++){
                for(int j=0;j<xh*4;j++){
                    if(j<xh){
                        xlsx.write(flh,1,i+1);
                        xlsx.write(flh,2,konglist[i]);
                        xlsx.write(flh,3,j+1);
                        xlsx.write(flh,4,"Target 1");
                        QString sql=QString("SELECT FAM FROM FluorescenceLvData WHERE PositionNumber=%1 AND CyclesNumber=%2").arg(i+1).arg(j+1);
                        QSqlDatabase db = dbHelper::openConnection();
                        QSqlQuery query(db);
                        QString drn;
                        if (!query.exec(sql)) {
                            qDebug() << "Query failed:" << query.lastError().text();
                            return; // 或者其他错误处理
                        }
                        while (query.next()) {
                            drn = query.value("FAM").toString();
                        }
                        qDebug()<<drn;
                        xlsx.write(flh,5,QString::number(drn.toDouble(),'f',2).toDouble());


                        xlsx.write(flh,6,QString::number(drn.toDouble()+famrn[i].toDouble(),'f',2).toDouble());
                        out<<QString::number(i+1)<<"\t";
                        out2<<QString::number(i+1)<<"\t";
                        out<<konglist[i]<<"\t";
                        out2<<konglist[i]<<"\t";
                        out<<QString::number(j+1)<<"\t";
                        out2<<QString::number(j+1)<<"\t";
                        out<<"Target 1"<<"\t";
                        out2<<"Target 1"<<"\t";
                        out<<QString::number(drn.toDouble(),'f',2)<<"\t";
                        out2<<QString::number(drn.toDouble(),'f',2)<<"\t";
                        out<<QString::number(drn.toDouble()+famrn[i].toDouble(),'f',2)<<"\t";
                        out2<<QString::number(drn.toDouble()+famrn[i].toDouble(),'f',2)<<"\t";
                        flh++;
                    }else if(j>=xh&&j<2*xh){
                        xlsx.write(flh,1,i+1);
                        xlsx.write(flh,2,konglist[i]);
                        xlsx.write(flh,3,j+1-xh);
                        xlsx.write(flh,4,"Target 2");
                        QString sql=QString("SELECT VIC FROM FluorescenceLvData WHERE PositionNumber=%1 AND CyclesNumber=%2").arg(i+1).arg(j+1-xh);
                        QSqlDatabase db = dbHelper::openConnection();
                        QSqlQuery query(db);
                        QString drn;
                        query.exec(sql);
                        while (query.next()) {
                            QString column1Value;
                            column1Value = query.value("VIC").toString();
                            drn=column1Value;
                            qDebug()<<drn;
                        }
                        xlsx.write(flh,5,QString::number(drn.toDouble(),'f',2).toDouble());
                        xlsx.write(flh,6,QString::number(drn.toDouble()+vicrn[i].toDouble(),'f',2).toDouble());
                        out<<QString::number(i+1)<<"\t";
                        out2<<QString::number(i+1)<<"\t";
                        out<<konglist[i]<<"\t";
                        out2<<konglist[i]<<"\t";
                        out<<QString::number(j+1-xh)<<"\t";
                        out2<<QString::number(j+1-xh)<<"\t";
                        out<<"Target 2"<<"\t";
                        out2<<"Target 2"<<"\t";
                        out<<QString::number(drn.toDouble(),'f',2)<<"\t";
                        out2<<QString::number(drn.toDouble(),'f',2)<<"\t";
                        out<<QString::number(drn.toDouble()+vicrn[i].toDouble(),'f',2)<<"\t";
                        out2<<QString::number(drn.toDouble()+vicrn[i].toDouble(),'f',2)<<"\t";
                        flh++;
                    }else if(j>=2*xh&&j<3*xh){
                        xlsx.write(flh,1,i+1);
                        xlsx.write(flh,2,konglist[i]);
                        xlsx.write(flh,3,j+1-2*xh);
                        xlsx.write(flh,4,"Target 3");
                        QString sql=QString("SELECT ROX FROM FluorescenceLvData WHERE PositionNumber=%1 AND CyclesNumber=%2").arg(i+1).arg(j+1-2*xh);
                        QSqlDatabase db = dbHelper::openConnection();
                        QSqlQuery query(db);
                        QString drn;
                        query.exec(sql);
                        while (query.next()) {
                            drn = query.value("ROX").toString();
                        }
                        xlsx.write(flh,5,QString::number(drn.toDouble(),'f',2).toDouble());
                        xlsx.write(flh,6,QString::number(drn.toDouble()+roxrn[i].toDouble(),'f',2).toDouble());
                        out<<QString::number(i+1)<<"\t";
                        out2<<QString::number(i+1)<<"\t";
                        out<<konglist[i]<<"\t";
                        out2<<konglist[i]<<"\t";
                        out<<QString::number(j+1-2*xh)<<"\t";
                        out2<<QString::number(j+1-2*xh)<<"\t";
                        out<<"Target 3"<<"\t";
                        out2<<"Target 3"<<"\t";
                        out<<QString::number(drn.toDouble(),'f',2)<<"\t";
                        out2<<QString::number(drn.toDouble(),'f',2)<<"\t";
                        out<<QString::number(drn.toDouble()+roxrn[i].toDouble(),'f',2)<<"\t";
                        out2<<QString::number(drn.toDouble()+roxrn[i].toDouble(),'f',2)<<"\t";
                        flh++;
                    }else if(j>=3*xh&&j<4*xh){
                        xlsx.write(flh,1,i+1);
                        xlsx.write(flh,2,konglist[i]);
                        xlsx.write(flh,3,j+1-3*xh);
                        xlsx.write(flh,4,"Target 4");
                        QString sql=QString("SELECT CY5 FROM FluorescenceLvData WHERE PositionNumber=%1 AND CyclesNumber=%2").arg(i+1).arg(j+1-3*xh);
                        QSqlDatabase db = dbHelper::openConnection();
                        QSqlQuery query(db);
                        QString drn;
                        query.exec(sql);
                        while (query.next()) {
                            drn = query.value("CY5").toString();
                        }
                        xlsx.write(flh,5,QString::number(drn.toDouble(),'f',2).toDouble());
                        xlsx.write(flh,6,QString::number(drn.toDouble()+cy5rn[i].toDouble(),'f',2).toDouble());
                        out<<QString::number(i+1)<<"\t";
                        out2<<QString::number(i+1)<<"\t";
                        out<<konglist[i]<<"\t";
                        out2<<konglist[i]<<"\t";
                        out<<QString::number(j+1-3*xh)<<"\t";
                        out2<<QString::number(j+1-3*xh)<<"\t";
                        out<<"Target 4"<<"\t";
                        out2<<"Target 4"<<"\t";
                        out<<QString::number(drn.toDouble(),'f',2)<<"\t";
                        out2<<QString::number(drn.toDouble(),'f',2)<<"\t";
                        out<<QString::number(drn.toDouble()+cy5rn[i].toDouble(),'f',2)<<"\t";
                        out2<<QString::number(drn.toDouble()+cy5rn[i].toDouble(),'f',2)<<"\t";
                        flh++;
                    }
                }
            }
        }
        if(true){
            xlsx.selectSheet("结果分析");
            xlsx.write(1,1,"仪器名称");
            xlsx.write(2,1,"创建日期");
            xlsx.write(3,1,"实验名称");
            xlsx.write(4,1,"实验结束时间");
            xlsx.write(1,2,"RT-PCR-96");
            xlsx.write(2,2,sanames[1]);
            xlsx.write(3,2,sanames[0]);
            xlsx.write(4,2,sanames[2]);
            out<<QString("结果分析\n");
            out2<<QString("结果分析\n");
            out<<"\n"<<"\n"<<"\n"<<"\n"<<"\n";
            out2<<"\n"<<"\n"<<"\n"<<"\n"<<"\n";
            out<<QString("仪器名称\t")<<QString("RT-PCR-96\n");
            out<<QString("创建日期\t")<<QString(sanames[1]+"\n");
            out<<QString("实验名称\t")<<QString(sanames[0]+"\n");
            out<<QString("实验结束时间\t")<<QString(sanames[2]+"\n");
            out2<<QString("仪器名称\t")<<QString("RT-PCR-96\n");
            out2<<QString("创建日期\t")<<QString(sanames[1]+"\n");
            out2<<QString("实验名称\t")<<QString(sanames[0]+"\n");
            out2<<QString("实验结束时间\t")<<QString(sanames[2]+"\n");
            QStringList tit;
            tit<<"编号"<<"样本孔"<<"样本名"<<"样本类型"<<"报告基团"<<"CRT"<<"Crt 平均值"<<"Quantity"<<"Quantity Mean"<<"y轴截距"<<"R²"<<"斜率"<<"扩增效率";
            out<<QString("编号\t")<<QString("样本孔\t")<<QString("样本名\t")<<QString("样本类型\t")<<QString("报告基团\t")<<QString("CRT\t")<<QString("Crt 平均值\t")<<QString("Quantity\t")<<QString("Quantity Mean\t")<<QString("y轴截距\t")<<QString("R²\t")<<QString("斜率\t")<<QString("扩增效率\n");
            out2<<QString("编号\t")<<QString("样本孔\t")<<QString("样本名\t")<<QString("样本类型\t")<<QString("报告基团\t")<<QString("CRT\t")<<QString("Crt 平均值\t")<<QString("Quantity\t")<<QString("Quantity Mean\t")<<QString("y轴截距\t")<<QString("R²\t")<<QString("斜率\t")<<QString("扩增效率\n");
            for(int i=0;i<tit.length();i++){
                xlsx.write(6,i+1,tit[i]);
            }
            QString kong,sample,tetype,lu,cq,cqt,qya,quaM;
            for(int i=0;i<ui->tableWidget->rowCount();i++){
                kong=ui->tableWidget->item(i,0)->text();
                sample=ui->tableWidget->item(i,1)->text();
                tetype=ui->tableWidget->item(i,2)->text();
                lu=ui->tableWidget->item(i,4)->text();
                cq=ui->tableWidget->item(i,5)->text();
                qya=ui->tableWidget->item(i,6)->text();
                xlsx.write(i+7,2,kong);
                xlsx.write(i+7,3,sample);
                xlsx.write(i+7,4,tetype);
                xlsx.write(i+7,5,lu);
                xlsx.write(i+7,6,cq);
                xlsx.write(i+7,8,qya);
                xlsx.write(i+7,9,qut[i]);
            }
            for(int i=0;i<ui->tableWidget->rowCount();i+=4){
                xlsx.write(i+10,10,QString::number(bcy5));
                xlsx.write(i+10,11,QString::number(r2cy5));
                xlsx.write(i+10,12,QString::number(kcy5));
                xlsx.write(i+10,13,QString::number(cucy5));
                xlsx.write(i+7,10,QString::number(bfam));
                xlsx.write(i+7,11,QString::number(r2fam));
                xlsx.write(i+7,12,QString::number(kfam));
                xlsx.write(i+7,13,QString::number(cufam));
                xlsx.write(i+8,10,QString::number(brox));
                xlsx.write(i+8,11,QString::number(r2rox));
                xlsx.write(i+8,12,QString::number(krox));
                xlsx.write(i+8,13,QString::number(curox));
                xlsx.write(i+9,10,QString::number(bvic));
                xlsx.write(i+9,11,QString::number(r2vic));
                xlsx.write(i+9,12,QString::number(kvic));
                xlsx.write(i+9,13,QString::number(cuvic));
            }
            for(int i=0;i<ui->tableWidget->rowCount();i++){
                kong=ui->tableWidget->item(i,0)->text();
                sample=ui->tableWidget->item(i,1)->text();
                tetype=ui->tableWidget->item(i,2)->text();
                lu=ui->tableWidget->item(i,4)->text();
                cq=ui->tableWidget->item(i,5)->text();
                qya=ui->tableWidget->item(i,6)->text();
                out<<kong<<"\t";
                out<<sample<<"\t";
                out<<tetype<<"\t";
                out<<lu<<"\t";
                out<<cq<<"\t";
                out<<qya<<"\t";
                out<<qut[i]<<"\t";
                out2<<kong<<"\t";
                out2<<sample<<"\t";
                out2<<tetype<<"\t";
                out2<<lu<<"\t";
                out2<<cq<<"\t";
                out2<<qya<<"\t";
                out2<<qut[i]<<"\t";
                if((i+1)%4==1){
                    out<<QString::number(bfam)<<"\t"<<QString::number(r2fam)<<"\t"<<QString::number(kfam)<<"\t"<<QString::number(cufam)<<"\n";
                    out2<<QString::number(bfam)<<"\t"<<QString::number(r2fam)<<"\t"<<QString::number(kfam)<<"\t"<<QString::number(cufam)<<"\n";
                }else if((i+1)%4==2){
                    out<<QString::number(brox)<<"\t"<<QString::number(r2rox)<<"\t"<<QString::number(krox)<<"\t"<<QString::number(curox)<<"\n";
                    out2<<QString::number(brox)<<"\t"<<QString::number(r2rox)<<"\t"<<QString::number(krox)<<"\t"<<QString::number(curox)<<"\n";
                }else if((i+1)%4==3){
                    out<<QString::number(bvic)<<"\t"<<QString::number(r2vic)<<"\t"<<QString::number(kvic)<<"\t"<<QString::number(cuvic)<<"\n";
                    out2<<QString::number(bvic)<<"\t"<<QString::number(r2vic)<<"\t"<<QString::number(kvic)<<"\t"<<QString::number(cuvic)<<"\n";
                }else if((i+1)%4==0){
                    out<<QString::number(bcy5)<<"\t"<<QString::number(r2cy5)<<"\t"<<QString::number(kcy5)<<"\t"<<QString::number(cucy5)<<"\n";
                    out2<<QString::number(bcy5)<<"\t"<<QString::number(r2cy5)<<"\t"<<QString::number(kcy5)<<"\t"<<QString::number(cucy5)<<"\n";
                }
            }
        }
        if(true){
            xlsx.selectSheet("下游加样表格");
            for(int i=0;i<15;i++){
                xlsx.setColumnWidth(i+1,18);
            }
            for(int i=0;i<32;i++){
                xlsx.setRowHeight(i+1,22);
            }
            // 创建一个Format对象
            // 创建一个Format对象
            QXlsx::Format format2;
            format2.setBorderStyle(QXlsx::Format::BorderMedium);
            format2.setHorizontalAlignment(QXlsx::Format::AlignHCenter);;
            QXlsx::Format format;
            format.setPatternBackgroundColor(QColor(152, 245, 255));
            format.setBorderStyle(QXlsx::Format::BorderMedium);
            format.setHorizontalAlignment(QXlsx::Format::AlignHCenter);;
            xlsx.write(1,1,"常-STR加样表格",format);
            for(int i=0;i<12;i++){
                xlsx.write(1,i+2,"",format);
            }
            format.setPatternBackgroundColor(QColor(0, 255, 0));
            xlsx.write(12,1,"Y-STR加样表格",format);
            for(int i=0;i<12;i++){
                xlsx.write(12,i+2,"",format);
            }
            format.setPatternBackgroundColor(QColor(255, 255, 0));
            xlsx.write(23,1,"mini-STR加样表格",format);
            for(int i=0;i<12;i++){
                xlsx.write(23,i+2,"",format);
            }
            int zmfl=3;
            for(char zm='A';zm<='H';zm++){
                QString kdata =QString(zm);
                xlsx.write(zmfl,1,kdata,format2);
                zmfl++;
            }
            zmfl=14;
            for(char zm='A';zm<='H';zm++){
                QString kdata =QString(zm);
                xlsx.write(zmfl,1,kdata,format2);
                zmfl++;
            }
            zmfl=25;
            for(char zm='A';zm<='H';zm++){
                QString kdata =QString(zm);
                xlsx.write(zmfl,1,kdata,format2);
                zmfl++;
            }
            for(int i=1;i<13;i++){
                xlsx.write(2,i+1,QString::number(i),format2);
                xlsx.write(13,i+1,QString::number(i),format2);
                xlsx.write(24,i+1,QString::number(i),format2);
            }
            QString L="";
            QString N="";
            QString LN="";
            QStringList hang,lie;
            for(int i=2;i<14;i++){
                hang.append(QString::number(i-1));
            }
            for(char kong1='A';kong1<='H';kong1++){
                lie.append(QString::number(kong1));
            }

            for(int i=3;i<11;i++){
                for(int j=2;j<14;j++){
                    L = lie[i-3];
                    N = hang[j-2];
                    LN = L + N;
                    for(int k = 0;k<ui->tableWidget->rowCount();k+=4){
                        if(ui->tableWidget->item(k,13)->text()=="常STR"||ui->tableWidget->item(k,13)->text()=="常STR+Y-STR"){
                            if(LN==ui->tableWidget->item(k,0)->text()){
                                QString sytj = ui->tableWidget->item(k,16)->text();
                                xlsx.write(j,i,sytj,format2);
                            }
                        }
                    }
                }
            }
            for(int i=3;i<11;i++){
                for(int j=2;j<14;j++){
                    L = lie[i-3];
                    N = hang[j-2];
                    LN = L + N;
                    for(int k = 0;k<ui->tableWidget->rowCount();k+=4){
                        if(ui->tableWidget->item(k,13)->text()=="常STR+Y-STR"){
                            if(LN==ui->tableWidget->item(k,0)->text()){
                                QString sytj = ui->tableWidget->item(k,16)->text();
                                xlsx.write(j+11,i,sytj,format2);
                            }
                        }
                    }
                }
            }
            for(int i=3;i<11;i++){
                for(int j=2;j<14;j++){
                    L = lie[i-3];
                    N = hang[j-2];
                    LN = L + N;
                    for(int k = 0;k<ui->tableWidget->rowCount();k+=4){
                        if(ui->tableWidget->item(k,13)->text()=="二代测序或mini-STR"){
                            if(LN==ui->tableWidget->item(k,0)->text()){
                                QString sytj = ui->tableWidget->item(k,16)->text();
                                xlsx.write(j+22,i,sytj,format2);
                            }
                        }
                    }
                }
            }
        }
        if(isc=="1"){
            QString directory = "./dataout";
            if(doutfl==1){
                directory=outpath;
            }
            QDir dir;
            if (!dir.exists(directory)) {
                dir.mkpath(directory); // 创建目录
            }
            QString fullPath = directory + "/" + fileName;
            QString fullPath2 = directory + "/" + fileName2;

            if (xlsx.saveAs(fullPath)) {
//#ifdef Q_OS_ANDROID
//                FtpHelpers *ftp=new FtpHelpers();
//                ftp->uploadFile(fullPath);
//#endif
                qDebug() << "文件保存成功：" << fullPath;
            } else {
                qDebug() << "文件保存失败";
            }
            if (xlsx.saveAs(fullPath2)) {
//#ifdef Q_OS_ANDROID
//                FtpHelpers *ftp=new FtpHelpers();
//                ftp->uploadFile(fullPath2);
//#endif
                qDebug() << "文件保存成功：" << fullPath2;
            } else {
                qDebug() << "文件保存失败";
            }
            // 关闭文件
            file.close();
            file2.close();
            if(doutfl!=1){
                QString directory1 = filep;
                if(filep!=""){
                    QDir dir1;
                    if (!dir1.exists(directory1)) {
                        dir1.mkpath(directory1); // 创建目录
                    }
                    QString fullPath = directory1 + "/" + fileName;
                    QString fullPath2 = directory1 + "/" + fileName2;

                    if (xlsx.saveAs(fullPath)) {
//#ifdef Q_OS_ANDROID
//                FtpHelpers *ftp=new FtpHelpers();
//                ftp->uploadFile(fullPath);
//#endif
                    } else {
                    }
                    if (xlsx.saveAs(fullPath2)) {
//#ifdef Q_OS_ANDROID
//                FtpHelpers *ftp=new FtpHelpers();
//                ftp->uploadFile(fullPath2);
//#endif
                    } else {
                    }
                }
            }
            if(doutfl==1){
                QString directory1 = outpath;
                if(filep!=""){
                    QDir dir1;
                    if (!dir1.exists(directory1)) {
                        dir1.mkpath(directory1); // 创建目录
                    }
                    QString fullPath = directory1 + "/" + fileName;
                    QString fullPath2 = directory1 + "/" + fileName2;
                    QString fullPath4 = directory1 + "/" + "_test.txt";
                    if (xlsx.saveAs(fullPath)) {
//#ifdef Q_OS_ANDROID
//                FtpHelpers *ftp=new FtpHelpers();
//                ftp->uploadFile(fullPath);
//#endif
                    } else {
                    }
                    if (xlsx.saveAs(fullPath2)) {
//#ifdef Q_OS_ANDROID
//                FtpHelpers *ftp=new FtpHelpers();
//                ftp->uploadFile(fullPath2);
//#endif
                    } else {
                    }
                }
            }
        }
    }else{
        //        QMessageBox::warning(nullptr, tr("警告"), tr("请确认表格中是否有数据"), QMessageBox::Yes);
    }
}
